在Selenium Python中通过css_selector点击图像
我有一段代码。
我只想通过点击上面的图片 up.gif 来隐藏按钮 hidebutton2。
请问我该如何使用 selenium 和 Python 来实现这个功能?
下面是从 css_selector 获取的源代码。
<IMG onclick=hidePackage() id=hideButton2 style="BORDER-TOP: #ff0000 1px solid; BORDER-RIGHT: #ff0000 1px solid; BORDER-BOTTOM: #ff0000 1px solid; BORDER-LEFT: #ff0000 1px solid; DISPLAY: block" src="../../scripts/jQueryFramework/plugins/jqGrid/themes/steel/images/up.gif">
1 个回答
0
与这个元素互动的最简单方法就是:
driver.find_element_by_id("hideButton2").click()
更新:
driver.find_element_by_css_selector("#hideButton2").click()