[英]How can I click random web elements?
I need to automate the page contains several comment entering option fields, for example here is the sample HTML code that page contains with 我需要自动执行包含几个注释输入选项字段的页面,例如,这是页面包含的示例HTML代码
<td id="comment57" class="childhdnshw text-left">
<span id="non_explain_income_0" title=""/>
<div id="explain_income_0_more" class="more ie_7_empty_div"/>
<span id="explain_income_0_text" class="dispno" style="display:none">
First td
is dynamic and span id
is dynamic and div id
is dynamic, I need to enter comment in this page using send keys and I need to select web elements by random how I can do that. 首先, td
是动态的, span id
是动态的, div id
是动态的,我需要使用发送键在此页面中输入评论,我需要随机选择网络元素。
You can find your elements by XPATH, but as your element id is dynamic, try to set your XPATH in a way that handle dynamic ids. 您可以通过XPATH查找元素,但是由于您的元素ID是动态的,请尝试以处理动态ID的方式设置XPATH。 Assuming the dynamic part is _0_
, then this will match: 假设动态部分是_0_
,那么它将匹配:
driver.find_element_by_xpath('//div[starts-with(@id,"explain_income_")]')
Same way you can match your td
and span
. 用同样的方法可以匹配td
和span
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.