WebUI_01
作者:互联网
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
# from selenium.webdriver.chrome.webdriver import WebDriver
# web = WebDriver(executable_path='chromedriver')
# 创建一个浏览器对象
driver = webdriver.Chrome()
driver.implicitly_wait(10) # 隐式等待 只针对定位操作,参数为最大等待时间
# 访问指定的url
driver.get('https://account.cnblogs.com/signin?returnUrl=https:%2F%2Fwww.cnblogs.com%2F')
# 查找需要操作的元素,对元素进行输入操作
we = driver.find_element(By.ID, 'mat-input-0')
# .clear() 清除之前输入的文字
we.clear()
we.send_keys('519755117@qq.com')
we2 = driver.find_element(By.ID, 'mat-input-1')
we2.clear()
we2.send_keys('FTFX1236')
WebDriverWait(driver, 10, 0.5).until(lambda method1: driver.find_element(By.CLASS_NAME, 'mat-button-wrapper'),
message='时间超时') # 显式等待
# 执行操作,点击
web = driver.find_element(By.CLASS_NAME, 'mat-button-wrapper')
web.click()
# 关闭这个webdriver的进程
sleep(10) # 强制等待
driver.quit()
标签:webdriver,01,mat,selenium,driver,WebUI,import,find 来源: https://www.cnblogs.com/tfxbk/p/16382751.html