click点击方法在web UI自动化中使用频率非常高,此方法就是模拟鼠标左键单击动作
click入参说明
1.首先我们来分析一下click方法的代码
| element): | |
| :参数 元素:元素或坐标 | :param element: The element or point to click. |
| \ | |
| :py:class:`selenium.webdriver.remote.webelement.WebElement` or :py:class:`Point` | |
| 使用说明如下: | Clicks on the given element or point. Common examples are:: |
| click(Point(200, 300)) | |
| 调用方法 | 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'))
欢迎关注