1 year ago
#388867
Tiền Matty
Python Selenium - Clicking a button inside an iframe that is inside an iframe, x2
so I'm trying to click a button, but it's inside an iframe, that is inside another iframe, that is inside another iframe.. I can get into the first iframe but I can't seem to be able to get into the third to press the button..
first iframe:
<iframe src="#hidden" class="Z6wXJz-G-6vcu3I0ZoM_B show active lightbox" title="Verification challenge" data-e2e="enforcement-frame" style="width: 302px; height: 290px;"></iframe>
selector: body > div:nth-child(2) > iframe
js path: document.querySelector("body > div:nth-child(2) > iframe")
xpath: /html/body/div[2]/iframe
full xpath: /html/body/div[2]/iframe
second iframe:
<iframe frameborder="0" scrolling="no" id="fc-iframe-wrap" class="fc-iframe-wrap" aria-label=" " style="width: 302px; height: 290px;" src="#hidden"></iframe>
selector: #fc-iframe-wrap
js path: document.querySelector("#fc-iframe-wrap")
xpath: //*[@id="fc-iframe-wrap"]
full xpath: /html/body/div/div[1]/div/iframe
third frame:
<iframe class="wrapper" id="CaptchaFrame" title="Visual challenge" src="about:blank" horizontalscrolling="no" verticalscrolling="no" scrolling="no"></iframe>
selector: #CaptchaFrame
js path: document.querySelector("#CaptchaFrame")
xpath: //*[@id="CaptchaFrame"]
full xpath: /html/body/div[2]/div[2]/div[1]/iframe
verify BUTTON:
<button aria-describedby="descriptionVerify" id="home_children_button" class="sc-bdnxRM dboBXq sc-kEqXSa iibXvF">Verify</button>
selector: #home_children_button
js path: document.querySelector("#home_children_button")
xpath: //*[@id="home_children_button"]
full xpath: /html/body/div/div/div[1]/button
And excuse my messy python code, I'm still learning..
print("trying to switch to iframe1")
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"body > div:nth-child(2) > iframe")))
print("im now in frame1")
print("trying to make token slot visible")
driver.execute_script('var element=document.getElementById("Token"); element.style.display="block";')
print("token slot is visible")
print("switching to captcha frame")
###The line below is where it's failing, it is timing out so not finding the correct captcha
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"#CaptchaFrame")))
print("im now in captcha frame")
print("trying to click verify button")
driver.find_element(By.CSS_SELECTOR, '#home_children_button').click()
#WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#home_children_button"))).click()
print("i clicked verify button..")
python
selenium
0 Answers
Your Answer