Skip to content

Pop up processing sometimes fails #600

Closed
@zhonghai9967

Description

@zhonghai9967

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.

Activity

zhonghai9967

zhonghai9967 commented on Jun 22, 2020

@zhonghai9967
Author

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

zhonghai9967

zhonghai9967 commented on Jun 22, 2020

@zhonghai9967
Author

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

mdmintz

mdmintz commented on Jun 22, 2020

@mdmintz
Member

@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

zhonghai9967 commented on Jun 22, 2020

@zhonghai9967
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 commented on Feb 6, 2021

@mdmintz
Member

I forgot to close this ticket when I released https://github.com/seleniumbase/SeleniumBase/releases/tag/v1.50.3 a few months ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    workaround existsYou can reach your destination if you do this...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mdmintz@zhonghai9967

        Issue actions

          Pop up processing sometimes fails · Issue #600 · seleniumbase/SeleniumBase