Closed
Description
try:
self.wait_for_and_accept_alert()
except: pass
In most cases, it is normal, but sometimes, the pop-up window cannot be closed and the browser is stopped.
Manually click "OK" in the pop-up window, wait a few seconds, the program runs normally.
The company's intranet cannot reproduce the problem.
Using chrome.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
zhonghai9967 commentedon Jun 22, 2020
A personnel file entry procedure.
About 50 people will appear once.
zhonghai9967 commentedon Jun 22, 2020
Please ignore the syntax indentation in the problem description. The indentation is correct in the program.
mdmintz commentedon Jun 22, 2020
@zhonghai9967 I might have a possible idea what's causing the issue.
self.click(SELECTOR)
actions are followed by aself.wait_for_ready_state_complete()
to make sure that any actions or page loads caused by the click are done processing. This makes a call toself.execute_script(...)
, but it turns out that this causes pop-ups to immediately go away. To compensate, I first check to see if a pop-up is present first (and skip the call if it is), but sometimes the pop-up is delayed enough that it comes a bit later, and therefore gets closed out byexecute_script
. This becomes an issue if the test then callsself.wait_for_and_accept_alert()
in the next step.I'm not sure what the best way to handle this is yet, but I do know a workaround:
If you expect a click action to open up a pop-up window, use
self.find_element(SELECTOR).click()
instead ofself.click(SELECTOR)
for these specific clicks. Then you can be sure that the pop-up will be there in the next step so that you can callself.wait_for_and_accept_alert()
safely.zhonghai9967 commentedon Jun 22, 2020
I used your method, and there is no longer the previous problem of being unable to close the popup window.
thank you!
mdmintz commentedon Feb 6, 2021
I forgot to close this ticket when I released https://github.com/seleniumbase/SeleniumBase/releases/tag/v1.50.3 a few months ago.