[英]Dynamic elements with Selenium and Python
I'm trying to fill a small form with Selenium, but it has dynamic elements that it doesn't let me capture in any way.我正在尝试用 Selenium 填写一个小表格,但它具有动态元素,它不允许我以任何方式捕获。 In this link you can see the form: https://www.asefasalud.es/在此链接中,您可以看到表格: https://www.asefasalud.es/
I have tried almost all the search elements, to capture the object, but none of them work.我已经尝试了几乎所有的搜索元素,以捕获 object,但它们都不起作用。
driver.find_element_by_xpath("//*[contains(@id, 'inputDiafnac')]").get(0).send_keys("2")
driver.find_element_by_xpath("//*[contains(@id, 'inputDiafnac')]").send_keys("2")
driver.find_element_by_xpath("//input[@id='inputDiafnac1']").send_keys("2")
driver.find_element_by_css_selector("#inputDiafnac1").send_keys("2")
driver.find_element_by_id("inputDiafnac1").send_keys("2")
I don't know if there is another way to capture these elements, thank you.不知道有没有其他方法可以捕捉到这些元素,谢谢。
I found something I think might work.我发现了一些我认为可能有用的东西。
driver.switch_to.frame(driver.find_element(By.CSS_SELECTOR, "[name='calcular-seguro-medico']"))
driver.find_element_by_id("inputDiafnac1").send_keys("2")
Once you are done with elements inside this frame, you will need to switch back to the top level frame using完成此框架内的元素后,您需要使用切换回顶层框架
driver.switch_to.default_content()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.