[英]how to find id by class name python selenium
<input class="select_step ON " id="step_9285985_select" name="step_9285985_select" type="checkbox" value="9285985">
I am automating the regular tasks of our project by python selenium. 我正在通过python selenium自动执行我们项目的常规任务。 struct at one step, Please help me.
第一步,请帮助我。
As per the above html code id="step_9285985_select"
randomly changing for every time browser opens through webdriver
(python Selenium). 按照上面的html代码
id="step_9285985_select"
,每次通过webdriver
(python Selenium)打开浏览器时都会随机更改。 I want to find the randomly generated "id"
by the class="select_step ON
or any other alternative. 我想通过
class="select_step ON
或任何其他替代方式找到随机生成的"id"
。
First find the element by CSS selector: 首先通过CSS选择器找到元素:
input_tag = driver.find_element_by_css_selector('input.select_step.ON')
Then get the id
attribute: 然后获取
id
属性:
print(input_tag.get_attribute('id'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.