zoukankan      html  css  js  c++  java
  • Python+Selenium之常用模块

    要用webdriver:from selenium import webdriver

    eg: driver = webdriver.Chrome()
          driver.maximize_window()
          driver.get("http://www.baidu.com")

    要用等待:from selenium.webdriver.common.by import By,from selenium.webdriver.support.ui import WebDriverWait,from selenium.webdriver.support import expected_conditions as EC

    eg: WebDriverWait(driver,15,0.5).until(EC.presence_of_element_located((By.NAME,"username"))).send_keys("Amy")

    要用perform:from selenium.webdriver.common.action_chains import ActionChains

    eg: ActionChains(driver).click(driver.find_element_by_id("inputCtrl0")).send_keys(Company).perform()

    要操作下拉框:from selenium.webdriver.support.select import Select

    eg: Select(driver.find_element_by_xpath("//select[@ng-model='accountInfoView.value.communication.code']")).select_by_index(2)

    要操作键盘:from selenium.webdriver.common.keys import Keys

    eg: driver.find_element_by_xpath("//input[@label='Postal Code']").send_keys(Keys.TAB)

    要用系统时间:from datetime import datetime

    eg: Account = "TestAccount" + datetime.now().strftime('%Y%m%d%H%M%S')

    要操作Excel:from openpyxl import load_workbook

    eg: wb = load_workbook('C:Portal_ScriptsTestData/Portal_TestData.xlsx')
          env = wb['Environment']
          envValue = env.cell(2,1).value

    要用sleep:from time import *

    eg: sleep(2)

  • 相关阅读:
    MyBatis原理分析
    oracle修改数据遇到的坑
    oracle查询时遇到的坑
    maven镜像
    易错题
    binlog2sql 安装使用
    Archery SQL审核平台搭建
    Docker安装
    夜莺n9e监控搭建
    influxdb安装
  • 原文地址:https://www.cnblogs.com/AmyHu/p/10655116.html
Copyright © 2011-2022 走看看