Browser not opening in the foreground

Hi,

I am trying to perform web automation where I need to click on an image after the page loads. When I click on the run(F5) button, sometimes the browser opens in foreground and the bot is able to recognize the image and click on it. But, many times, the browser opens but it is not in the foreground and the bot waits till the timeout and then throws an error. However, during the timeout period, if I click on the browser button in the task bar and maximize it, the bot is able to recognize the image and click on it. How do I always open the browser in the foreground?

Any help will be highly appreciated.

Regards,

3 Likes

If you are able to access the selector information You can use the Activate Activity. Also there is a maximise window activity which may also have the same effect. Both should bring the window to the front regardless of what else is open.

If you cannot see the selector information then you will probably have to automate the steps you took manually - e.g. click the Internet Explorer icon on the task bar

4 Likes

Hi Richard,

I tried using different windows activities like maximize window, show window, etc. but no success.
Will try to use activate activity and update.

Regards,

Tried using activate activity as well but, no success.

Activate activity does not work every time. It works sometimes. Sometimes, it does not.

1 Like

Why using click image within a browser?

Because I am unable to create a reliable selector.

you have to put minimize maximize both to bring it up .

In our case all the bots in production are getting impacted due to an Updgrade on the Environment( IE/JAva applet based windows). I wanted to know what is the root cause so that we can correct the root cause rather than upgrading production code of dozens of processes.

HI Team,
I am facing one issue in uipath, please find below the issue.
1.) Application not coming in foreground when running on VM in unattended mode
2.) tried all the way to make it in foreground using activate window activity and other , same code is running fine when we login to the system …
please help us .

It works for me when I use attach window activity with show window activity in it.

Hey,
Greetings!

Did u get any solution for this?

Hi @Pratiksha,
Yes we got the solution this was happening due to a .net patch , which had removed/uninstalled from the VM control panel.
Patch name KB4054852 should not be there in prod vm as it hinders the ui studio. hope it will help you as well .let me know if you still face this issue after removing the .net patch.

Regards
Raj kumar

Hi tarunch23,

Go to the application and access it’s Properties panel.

Change the Dropdown value in “Run” to Maximized and then click on “Apply”.

The window will always open full screen and will have focus.

P.S : You’ll require administrator privileges to make these changes. You can use this for any application which gives you problems while trying to get it in focus.

Hey @rajait07 , can you explain me more in details. I also having same issue.

I cant make an IE browser to come in front for the life of me if the windows 10 start menu is in front, i have a simple open browser activity navigating to any site and inside as first activity i tried show window, maximize (with and without minimize first), invoke method (bringtoforeground), send hotkey windows up, windows+d, and nothing works…

I hope this helps:

The workaround to this is to minimize the window using the Attach Window and the Minimize Window Activities and then use the Browser activity to open the window in the foreground.

Here is a screen shot of my Process.xaml. It works with two Browser applications, and one of them is a terrible application that needs to have the Popup Visible for the process to move forward.

You can see that the “Good Application” window is minimized to get out of the way of the “Bad” window and once the work is done with the Bad window, the Good Window is brought back up, and further work on the Good window is resumed.

Tip:
There is no activity to specifically Minimize/Maximize Browser windows - therefore you have to use Attach Window activity to do this
When you use Attach Window, use the same selector that you used to open the Browser application using Attach Browser activity.
Or if you are using an Open Browser activity, then use an Attach Browser activity to get the selector and use it in the Attach Window to minimize or maximize the window

None of these user provided fixes work reliably. And even if they did I should not have to make a multi-step process like Andy outlines to open a simple browser window.

I’d like to ask is the UI Path development team has made any progress on this issue. Opening a useable browser window should be RPA 101.

I see that this is a bit of an old question, but I’ll post a solution that has worked quite well for me when having multiple browser windows open:

The key here is to use a Send Hotkey Activity that sends Win+Up as the first Activity inside the Do-sequence of an Attach Browser Activity. This will bring the browser-window in question to the foreground.

Hope it can be of use to someone.

6 Likes

The issue still exists btw

Hello @okakosolioks ,

I agree that this a bit of a quirky thing get our hands around. The Window modes (Restore, Maximize, Minimize, Close) are functions of a Window object and not the site within the Browser itself. In this case, it’s the Chrome Browser Window application named chrome.exe .

Therefore, you have to take a slight detour and use the Window Activities :

image

Here is how I did it and I’ve confirmed that it works with Chrome. (Testing info below along with the xaml file attachment)

  1. Open the Browser as you would normally do using Open Browser activity
  2. Add an Attach Window Activity and select your Website window - In this case I have selected the uipath.com browser window that is already open

These are the two important steps:

2.1 In the properties of the Attach Window, create and assign a variable to the ApplicationWindow property - this is your Window handle
3. Next, add a Maximize Window activity inside the Attach Window and then assign the variable you created in step 2.1 to it!

Note: The sequence will run even if you don’t assign the variable to Maximize Window activity, but the Window will not remain in the foreground once it’s maximized. :neutral_face:

Do all your Browser actions outside of the Attach Window , because these are Browser actions and will not work inside an Attach Window scope

Testing:

Test 1:

  1. Open Chrome Browser.
  2. Reduce it’s size and then close it
  3. Run Automation

When the Robot opens the window, it will opened in a smaller size and then maximized to appear in the foreground

Test 2:

  1. Close the Browser Window after Maximizing it
  2. Run Automation

When the Robot opens it, the Window will show up maximized in the foreground straight way.

Seq_Maximize_or_Restore_Window.xaml (8.2 KB)