![](/img/trans.png)
[英]How to find element by part of its id name in selenium with python
[英]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">
我正在通過python selenium自動執行我們項目的常規任務。 第一步,請幫助我。
按照上面的html代碼id="step_9285985_select"
,每次通過webdriver
(python Selenium)打開瀏覽器時都會隨機更改。 我想通過class="select_step ON
或任何其他替代方式找到隨機生成的"id"
。
首先通過CSS選擇器找到元素:
input_tag = driver.find_element_by_css_selector('input.select_step.ON')
然后獲取id
屬性:
print(input_tag.get_attribute('id'))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.