在python绑定中单击带有selenium的图像

2024-04-19 19:32:21 发布

您现在位置:Python中文网/ 问答频道 /正文

<a onkeypress="if(event.keyCode == 13 || event.which == 13){ClientReportRpt…_ctl02.ActionHandler('Toggle','118iT0R0R0x1');}return false;" onclick="ClientReportRptMain_ctl02.ActionHandler('Toggle','118iT0R0R0x1');return false;" style="cursor:pointer;" tabindex="4"> <img border="0" alt="+" src="/SIMS/Reserved.ReportViewerWebControl.axd?ReportSession=cfsd…Type=ReportImage&ResourceStreamID=10.50.4000.0TogglePlus.gif"> </img> </a>

这是代码的一部分,网页上有许多类似的图像,其中值“118iT0R0R0x1”和tab index=“4”对于相同图像在网页中的不同位置不是常量。 我在python绑定中使用Selenium。任何帮助都将不胜感激。谢谢:)


Tags: 图像eventfalse网页whichimgreturnif
1条回答
网友
1楼 · 发布于 2024-04-19 19:32:21

锚点有“onclick”处理程序,而不是图像。你需要“点击”锚。你知道吗

anchor_element = browser.find_element_by_*(...)
anchor_element.click()

其中anchor_element自我解释。要查找定位元素,请执行以下操作:

http://selenium-python.readthedocs.org/locating-elements.html

我不能说更多,因为您的代码片段只包含两个元素。为了找到正确的元素,我必须知道更多关于哪些元素是你在寻找。。。你知道吗

相关问题 更多 >