When I have selenium click a button on the webpage, a popup opens and I've tried a few ways to switch to the iframe popup but I'm using
WebDriverWait(driver, 10).until()
and after 10 seconds it will just timeout. I'm guessing it never recognizes the iframe and I'm sure it must be because I'm having it look for it incorrectly. Here is the HTML:
<div class="indeed-apply-popup" tabindex="0" id="indeed-ia-1530049657884-0-modal" style="position: absolute; left: 216px; top: 80px;"><div class="indeed-apply-container" id="indeedapply-modal-preload-container" style="height: 572px; width: 540px;"><div class="indeed-apply-branding" id="indeedapply-modal-preload-branding"></div><div class="indeed-apply-bd" id="indeedapply-modal-preload-bd"><iframe name="indeedapply-modal-preload-iframe" id="indeedapply-modal-preload-iframe" scrolling="no" frameborder="0" src="https://apply.indeed.com/indeedapply/xpc?v=5#%7B%22cn%22:%22onESpqgxSb%22,%22ppu%22:%22https://www.indeed.com/robots.txt%22,%22lpu%22:%22https://apply.indeed.com/robots.txt%22,%22setupms%22:1530049660417,%22preload%22:true,%22iaUid%22:%221cgv11tjq1b2b0o4%22,%22parentURL%22:%22https://www.indeed.com/jobs?q=it&l=252C%2520FL&vjk=ff1572a95b1b84bf%22%7D" style="border: 0px; vertical-align: bottom; width: 100%; height: 100%;"></iframe></div></div></div>
the popup that contains the iframe has HTML like this:
<div class="indeed-apply-popup" tabindex="0" id="indeed-ia-1530049657884-0-modal" style="position: absolute; left: 208px; top: 80px;"><div class="indeed-apply-container" id="indeedapply-modal-preload-container" style="height: 572px; width: 540px;"><div class="indeed-apply-branding" id="indeedapply-modal-preload-branding"></div><div class="indeed-apply-bd" id="indeedapply-modal-preload-bd">
The part of my code I'm using looks like this:
for item in page_results:
item.click()
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, 'indeed-apply-button-label'))
)
apply_button = driver.find_element_by_class_name('indeed-apply-button-label')
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CLASS_NAME, 'indeed-apply-button-label'))
)
apply_button.click()
WebDriverWait(driver, 10).until(
EC.frame_to_be_available_and_switch_to_it((By.NAME, 'indeedapply-modal-preload-iframe'))
)
WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//*[@id='form-action-continue']"))
)
continue_button = driver.find_element_by_id('form-action-continue')
continue_button.click()
But the error I get is:
line 70, in <module>
EC.frame_to_be_available_and_switch_to_it((By.NAME, "indeedapply-modal-preload-iframe"))
line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
I've tried driver.switch_to.frame() on it's own after and before the WebDriverWait, still nothing. Even if I get it to not show the timeout message anymore, the following
continue_button
Is not recognizable and then I get an error saying the element doesn't exist.