selenium python 编码格式 页面元素显式、隐式等待 鼠标悬浮

来源:互联网 发布:vscode md转html 编辑:程序博客网 时间:2024/06/01 20:56

1. 设置格式

# coding:utf-8# coding:cp936

2. 设置web页面元素隐式等待

browser.implicitly_wait(30)

3. 鼠标悬浮

from selenium.webdriver.common.action_chains import *    suspension = browser.find_element_by_xpath("element") ActionChains(browser).move_to_element(suspension).perform() 

4. 显式等待

from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as EC  message_log = WebDriverWait(broswer, 5, 0.5).until(EC.presence_of_element_located((By.XPATH,'//*[@id="tabLi2"]/a')))  message_log.click()

参考:
1.Python selenium —— 一定要会用selenium的等待,三种等待方式解读

阅读全文
0 0
原创粉丝点击