Skip to content

Pop up processing sometimes fails #600

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
zhonghai9967 opened this issue Jun 22, 2020 · 5 comments
Closed

Pop up processing sometimes fails #600

zhonghai9967 opened this issue Jun 22, 2020 · 5 comments
Labels
workaround exists You can reach your destination if you do this...

Comments

@zhonghai9967
Copy link

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.

@zhonghai9967
Copy link
Author

A personnel file entry procedure.
About 50 people will appear once.

@zhonghai9967
Copy link
Author

Please ignore the syntax indentation in the problem description. The indentation is correct in the program.

@mdmintz
Copy link
Member

mdmintz commented Jun 22, 2020

@zhonghai9967 I might have a possible idea what's causing the issue. self.click(SELECTOR) actions are followed by a self.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 to self.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 by execute_script. This becomes an issue if the test then calls self.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 of self.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 call self.wait_for_and_accept_alert() safely.

@zhonghai9967
Copy link
Author

I used your method, and there is no longer the previous problem of being unable to close the popup window.
thank you!

@mdmintz mdmintz added the workaround exists You can reach your destination if you do this... label Jun 23, 2020
@mdmintz
Copy link
Member

mdmintz commented 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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
workaround exists You can reach your destination if you do this...
Projects
None yet
Development

No branches or pull requests

2 participants