So I am scraping a site that has a random popup via an iframe sporadically appear as you scroll down the page. On the iframe there is a button to get rid of it. However, it's hard to be certain when it will appear. I can get round this by just having it try and find the iframe every time it tries to scroll down the page
try:
page.frame_locator('#aframe').locator('button:has-text("click me")').click()
except:
continue
This works. But it's super slow because it waits for 30 seconds to try and find the iframe each time. I tried just lowering the timeout, but this doesn't seem to be an option for a frame locator? Is there a way to either: (a) lower the timeout for this operation, or (b) manually stop the script for two seconds and then do an immediate check. Something like:
time.sleep(2)
if *check for iframe* == False:
continue
else:
*click on button*
.query_selector()instead of.locator()).