I switched to a frame inside a frame with selenium, and I accessed to that frame, but I'm unable to find elements inside the frame using find_element_by_tag_name
or find_element_by_xpath
, I'm sure the element exists, but I cannot find it and click on it with selenium.
page > frame1(elements: checkbox) > frame2(elements: imgs , buttons)
There are buttons in frame2 I want to click on it, and frame2 shown after checkbox clicked. Here is my code:
driver = webdriver.Firefox(r"C:\Users\[profilename]\Desktop\devloper\selenium\gecko")
driver.get(url)
sleep(10) #to make sure that everything loaded
#the first frame (success to access and clicked):
driver.switch_to.frame(0)
click1 = driver.find_element_by_xpath("//*[@id=\"anchor\"]")
click1.click()
sleep(5) #to make sure that everything loaded
iframe = driver.find_element_by_tag_name("iframe")
driver.switch_to.frame(iframe)
sleep(3)
frame2_element = driver.find_element_by_tag_name("button")
frame2_element.click()
Error msg:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element
I used find_element_by_tag_name
and before that i tried XPATH and it had same error.
I tried hard to explain everything i'm not good with explaining things to people so i hope u understand me, and please tell me what to do :( .
The url is : reCAPTCHA demo