Solved

Issue Closing a Chrome Browser Window

  • 23 March 2023
  • 4 replies
  • 421 views

Userlevel 2
Badge +8

I have a Task that is attempting to close a Chrome browser window but it cannot do so because of a Chrome dialog warning that navigating away from the page could result in loss of data.

  1. I cannot use recorder to capture this dialog because having it on screen freezes ALL my Chrome windows, not just the one it is trying to close. I can’t even switch to another Chrome window while this dialog is up.
  2. I’ve tried sending a “ENTER” keystroke to the page but that does not press the “Leave” button that has the focus.
  3. I cannot use Taskkill to close Chrome because this closes all Chrome windows including my dev windows I’m working, which stops the BOT from running.
  4. Update: Also tried changing the Chrome Setting to block popups in chrome on this site. That did NOT work either.

If anyone has a work around for this I’d really appreciate it!

icon

Best answer by JMarino 24 March 2023, 15:26

View original

4 replies

Userlevel 4
Badge +14

Hi @JMarino ,

Please try with condition of : If → Window is found in a window(Image recognition)

If found than use key strokes → ctrl + w to close the window.

else → nothing.

Userlevel 2
Badge +8

@Zaid Chougle I did try image recognition and could not get it to work. Another thing I tried was capturing the name of the active Window which is “Leave Site?” and I attempted to close that window. But all it does is close the “Leave Site ?” window and leaves the browser open.

Userlevel 2
Badge +8

After a lot of time on this last night I did finally find something that allowed this to close.

  1. You have to start up Recorder to start recording actions BEFORE this dialog appears
  2. Do something on the page to get the dialog
  3. Record capturing some text on the dialog so you can get the window properties and get the window saved as a variable
  4. Stop recording
  5. Add a Activate Window command to make sure that is has the focus
  6. Add a Simulate Keystrokes command and use ENTER or RETURN (note that object cloning the “Leave” button does NOT work. AA cannot perform click actions in this window for some reason)

It take 20 seconds for the keystroke to close the dialog and the browser but at least it works.

Badge

Is this still the best solution? I’m using this as well and it is killing the performance having to wait that long to close a page. Would be nice to have something faster.

Reply