天天看點

selenium常用APIselenium常用API

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表達式:

selenium常用APIselenium常用API
selenium常用APIselenium常用API

滑鼠事件:

from selenium.webdriver.common.action_chains import ActionChains
           

ActionChains(driver) : 用于生成模拟使用者行為

perform():執行存儲行為

動作:

selenium常用APIselenium常用API

組合使用:

ActionChains(driver).move_to_element(ele).perform()
           

鍵盤事件:

from selenium.webdriver.common.keys import Keys
           
selenium常用APIselenium常用API

selenium中的等待方法:

import time
time.sleep()
           
implicitly_wait()

from selenium.webdriver.support.ui import WebDriverWait
           

對話框事件:

selenium常用APIselenium常用API

繼續閱讀