Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Selenium can't found valid item from iframe

I have code:

self.driver.execute_script(f'document.getElementsByName("h-captcha-response")[0].setAttribute("h-captcha-response", "{token}")')
self.driver.execute_script(f'document.getElementsByName("g-recaptcha-response")[0].setAttribute("g-recaptcha-response", "{token}")')
self.driver.find_element_by_id('checkbox').click()
time.sleep(5)

and that code don’t click at the item with id checkbox (check screenshot)

i think the iframe upper makes big problems (check screenshot)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if this is right version of solving problem, how to refocus Selenium onto that iframe?

>Solution :

I dont think that driver.switchTo().frame(iframe); would work but

wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@name,'a-')]")));

might.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading