前言
click點擊方法在web UI自動化中使用頻率非常高,此方法就是模擬鼠標左鍵單擊動作
click入參說明
1.首先我們來分析一下click方法的代碼
click(element): | |
""" | |
:參數 元素:元素或坐標 | :param element: The element or point to click. |
:type element: str, unicode, :py:class:`HTMLElement`, \ | |
:py:class:`selenium.webdriver.remote.webelement.WebElement` or :py:class:`Point` | |
使用說明如下: | Clicks on the given element or point. Common examples are:: |
click("Sign in") | |
click(Button("OK")) | |
click(Point(200, 300)) | |
click(ComboBox("File type").top_left + (50, 0)) | |
""" | |
調用方法 | _get_api_impl().click_impl(element) |
click案例分析
1、點擊文字,
start_chrome("https://cn.bing.com/")
highlight("地圖") # 高亮展示
time.sleep(5)
click("地圖")
kill_browser()
2、點擊按鈕,通過calss定位
start_chrome("https://www.icourse163.org/")
time.sleep(5)
cell= S(".u-search-icon")
highlight(cell)
time.sleep(5)
click(cell)
time.sleep(5)
kill_browser()
3、點擊按鈕,通過id定位
click(S('#dologin'))
歡迎關注