selenium:使用python单击dynamic单选按钮

2024-04-26 07:01:27 发布

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

我试着点击一个动态网页上的单选按钮。我尝试了classname、xpath,但没有任何效果。在

包含单选按钮的代码是:

<input id="radiofield-1247-inputEl" class="x-form-field x-form-radio x-form-cb" type="button" hidefocus="true" autocomplete="off" role="radio">

按钮旁边有一个标签。在

^{2}$

我试过了:

driver.find_element_by_xpath("//*[@type='radio'][@class='#class here'") #.click() and this doesn't work. 

我尝试传递绝对xpath,但也失败了。没有要搜索的名称或id。在


Tags: 代码formid网页inputtype动态按钮
1条回答
网友
1楼 · 发布于 2024-04-26 07:01:27

您正在尝试type="radio",而在提供的HTML上,type="button"。。。在

尝试以下操作XPath

driver.find_element_by_xpath('//input[contains(@id, "radiofield-")][@role="radio"]')

相关问题 更多 >