Helium文件3-click點選
阿新 • • 發佈:2020-08-21
前言
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'))