selenium常用API
程序员文章站
2022-03-22 13:11:44
...
selenium常用API
定位元素:
find_element_by_id()
find_element_by_name()
find_element_by_class_name()
find_element_by_tag_name()
find_element_by_link_text()
find_element_by_partial_link_text()
find_element_by_xpath()
find_element_by_css_selector()
元素操作方式:
ele.clear()
ele.send_keys()
ele.click()
ele.submit()
xpath表达式:
鼠标事件:
from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver) : 用于生成模拟用户行为
perform():执行存储行为
动作:
组合使用:
ActionChains(driver).move_to_element(ele).perform()
键盘事件:
from selenium.webdriver.common.keys import Keys
selenium中的等待方法:
import time
time.sleep(3)
implicitly_wait()
from selenium.webdriver.support.ui import WebDriverWait
对话框事件: