[英]selenium : Click on dynamic radio button using python
I'm trying to click on a radio button on a web page which is dynamic. 我正在尝试单击动态网页上的单选按钮。 I tried classname, xpath and nothing works. 我尝试了classname,xpath,但没有任何效果。
The code that contains the radio button is : 包含单选按钮的代码为:
<input id="radiofield-1247-inputEl" class="x-form-field x-form-radio x-form-cb" type="button" hidefocus="true" autocomplete="off" role="radio">
There is a label which is adjacent to the button. 按钮旁边有一个标签。
<label id="radiofield-1247-boxLabelEl" class="x-form-cb-label x-form-cb-label-after" for="radiofield-1247-inputEl">Yes</label>
I tried : 我试过了 :
driver.find_element_by_xpath("//*[@type='radio'][@class='#class here'") #.click() and this doesn't work.
I tried passing the absolute xpath, which also fails. 我尝试传递绝对的xpath,这也失败了。 There is no name or id to do a search for. 没有要搜索的名称或ID。
You're trying type="radio"
while on provided HTML
it's type="button"
... 您正在尝试使用type="radio"
而在提供的HTML
上是type="button"
...
Try following XPath
: 尝试遵循XPath
:
driver.find_element_by_xpath('//input[contains(@id, "radiofield-")][@role="radio"]')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.