[英]I am unable to iterate(locate) this input filed from selenium python, every time id changed, and full Xpath is also not working
Hy all, I am unable to iterate this input filed from selenium python, every time id changed, and full Xpath is also not working.大家好,我无法迭代从 selenium python 提交的此输入,每次 id 更改,并且完整的 Xpath 也不起作用。 URL: https://support.google.com/blogger/answer/3091837
URL: https://support.google.com/blogger/answer/3091837
i tried already: -我已经试过了:-
driver.find_element_by_name("blog_URL").click()
driver.find_element_by_xpath('//*[@id="render_api158171433--blog_URL"]').click()
driver.find_element_by_xpath("/html/body/div[8]/div/section/div/div[1]/article/section/div/div[2]/div[1]/form/div[1]/input").click()
driver.find_element_by_id('render_api535892960--blog_URL')[2].click()
Your <input>
has an slippery id but its name seems to be unique name="blog_URL"
, so you could use find_element_by_name你的
<input>
有一个滑的 id 但它的名字似乎是唯一的name="blog_URL"
,所以你可以使用find_element_by_name
Anyway when an id or class changes every time, findById or xpath with exact values does not help.无论如何,当 id 或 class 每次都更改时,具有精确值的 findById 或 xpath 无济于事。
You can try other approaches such as: looking for neighbors, parents, children,sibling, etc., which can be located and then navigate until to find your slippery <input>
.您可以尝试其他方法,例如:寻找邻居,父母,孩子,兄弟姐妹等,可以定位然后导航直到找到您的滑
<input>
。 This will be a little expensive!!这会有点贵!!
Samples according to your html:根据您的 html 的样品:
parentElement = driver.find_element_by_id("myFormId")
childElementsOfForm = parentElement.find_elements_by_xpath(".//*")
<input>
in another child of it.<input>
在它的另一个孩子中。parentElement = driver.find_element_by_id("myFormId")
elementList = parentElement.find_elements_by_tag_name("input")
Iterate them and search an input whose id starts with render_api迭代它们并搜索 id 以render_api开头的输入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.