# Switch browser : it works, but not visible at screen

**URL:** <https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180>\
**Category:** SeleniumLibrary\
**Created:** [27 July 2021 07:00 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180 "2021-07-27T07:00:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [27 July 2021 07:00 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/1 "2021-07-27T07:00:24Z")

</div>

Hi all,  
I’m a new user of Robot Framework, i m doing simples actions on browsers.  
When i use Switch Browser, it works : actions are made on my differents sessions but not at screen. there isnt visual switch. I need to demonstrate the RF work and at the switch browser moment it’s not really clear.  
It is a normal thing ?  
It is possible to show at screen the switch browser to be able to continue to see the currents actions ?

Thanks

Fabrice

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [28 July 2021 01:44 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/2 "2021-07-28T01:44:16Z")

</div>

Hi Fabrice,

At first It wasn’t clear what you were asking so I adapted the example from the documentation [Switch Browser](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Switch%20Browser) and created the example below that demonstrates what I think you are asking.

When I run this example, it opens a firefox window to [google.com](http://google.com), it then opens a chrome window to [yahoo.com](http://yahoo.com) which now sits in front of the firefox window, because I didn’t full screen the chrome window you can see some of the firefox window but it’s obscured.

when `Switch Browser` switches to firefox, chrome remains as the front most window, you can see some activity is happening on the firefox window but can’t see what because it’s behind the chrome window.

If I’m understanding correctly you were expecting the firefox window to come to the front when `Switch Browser` is called?

I’m not sure whether this is expected behaviour or not, perhaps someone who is more knowledgable than me on SeleniumLibrary can confirm? I don’t see any mention in the documentation about this.

I also don’t know if different platforms affect this behaviour, I reproduced what I believe is you issue on MacOS 11.2, it may behave differently on windows? I would expect it to be the same on Linux as MacOS.

Another option if you really need the browser window in the front for people watching the automation could be to use another library to bring the browser to the foreground [SikuliLibrary](https://github.com/rainmanwy/robotframework-SikuliLibrary) or [flaui](https://github.com/GDATASoftwareAG/robotframework-flaui) might be useful to do that.

FYI - the `Capture Page Screenshot` call does allow me to confirm the actions I expected were performed in the browser I expected.

```python
***Settings***
Library SeleniumLibrary

***Test Cases***
Fabrice
	Open Browser http://google.com	ff
	Location Should Contain google.com
	Open Browser http://yahoo.com	gc	alias=second
	Location Should Contain yahoo.com
	Switch Browser 1 # index
	Page Should Contain Gmail
	Input Text q robot framework
	Press Keys q ENTER
	Capture Page Screenshot
	Switch Browser second # alias
	Page Should Contain Company info
	Input Text p robot framework
	Press Keys p ENTER
	Capture Page Screenshot
	Close All Browsers

```

I don’t know how much help this is, hopefully some,

Dave.

---

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [28 July 2021 05:53 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/3 "2021-07-28T05:53:59Z")

</div>

Hi Dave,  
Thanks for your answer. It 's exactly that. When i call Switch Browser, i want my active browser on the first plan, to see the currents actions.  
When i try your example, it is ok for the results but not on live : there is no visual switch of browsers.  
i need to show to anothers persons and it would be better  
if you have a idea, i take it…  
Thanks again

---

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [28 July 2021 06:26 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/4 "2021-07-28T06:26:52Z")

</div>

I m gonna see the libraries that you told me  
Thx  
Fabrice

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [29 July 2021 01:00 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/5 "2021-07-29T01:00:26Z")

</div>

Hi Fabrice,

From my usage of SeleniumLibrary, I have noticed that sometimes the browser will jump to the foreground but i’m not sure what triggers it to happen, I thought it was the click keyword so I tried adding a step `Click Element q` but that didn’t work so I didn’t suggest it, but maybe it’s a click link or it might be the browser doing it when a page loads I don’t know.

[SikuliLibrary](https://github.com/rainmanwy/robotframework-SikuliLibrary) is a great tool to have as an all purpose last resort, it works by clicking images so it works on every os / every application, but it’s not always the most accurate especially if things look visually similar.  
[flaui](https://github.com/GDATASoftwareAG/robotframework-flaui) allows you to use xpaths to identify object in an application but it only works with windows I wish I knew of something similar for MacOS and Linux

When you switch browser are the browser sessions different browsers or the same? i.e. edge and firefox or chrome and chrome? if they are different then having SikuliLibrary click the browsers icon on the taskbar / dock / etc might be all you need to do, then return to SeleniumLibrary 🤞🏻

It might also be worthwhile raising a feature request with SeleniumLibrary project to have an option on the `Switch Browser` keyword to bring the browser to the foreground, not sure if they’ll be able to do that, depends if Selenium has that capability, but no harm in asking.

Dave.

---

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [29 July 2021 06:04 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/6 "2021-07-29T06:04:07Z")

</div>

HI Dave,

Thanks again for these informations. I must to see SikuliLibrary asap. For flaui, unfortunatly i 'm under Linux.  
To answer you, i use the same browser : In multi Browser sessions of firefox. If i find anything i ll write the solution here.

Fabrice

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [29 July 2021 08:07 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/7 "2021-07-29T08:07:18Z")

</div>

Hi Fabrice,

In that case SikuliLibrary is the only library I know will work for you, but because you are using 2 firefox sessions it might be difficult to tell them apart, which distro / window manager are you using? the reason I ask, if you are using something like mint that has a windows style look and feel with a task bar then the icon combined with text on the task bar might be unique, but if your using something like elementary os with a dock it could be difficult to tell the 2 firefox sessions apart.

If I think of anything else i’ll mention it,

Dave.

---

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [29 July 2021 08:21 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/8 "2021-07-29T08:21:18Z")

</div>

Hi dave,

Apparentlly window management is XFCE…

Fabrice

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [29 July 2021 08:32 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/9 "2021-07-29T08:32:31Z")

</div>

Hi Fabrice,

Not sure of your programming skills in python? but you can create python functions and use them as keywords in robot framework.

I found this example for window management in XFCE with python:

> <https://unix.stackexchange.com/questions/385949/python-script-to-minimize-all-but-one-window-kills-panel>

I’ve never done this myself, but hopefully you could adapt that example to create a python function that activates a window based on a window title.  
Then you could use [Get Title](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Get%20Title) after Switch Browser to get the title then pass the title to the python function.

I did have a look at the [pywinauto](https://github.com/pywinauto/pywinauto) python library, this is something i’d been keeping an eye on as it was aiming to be a cross platform test automation library but it’s activate window is windows only still.

Dave.

---

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [29 July 2021 08:38 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/10 "2021-07-29T08:38:58Z")

</div>

Dave,

I m not a devloper, just an “evolued” user, but i m going to look at this way

thx again

Fabrice

---

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [29 July 2021 13:54 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/11 "2021-07-29T13:54:23Z")

</div>

Hi Dave,

It’s all right, i found a solution. With your link, i made searches and i done that :

On the Keyword “Switch Browser” of SeleniumLibrary/Keywords on the “try”, i ve added

> handle\_of\_the\_window = self.driver.current\_window\_handle  
> self.driver.switch\_to.window(handle\_of\_the\_window)  
> self.driver.minimize\_window()  
> self.driver.set\_window\_rect(0, 0)  
> self.driver.maximize\_window()

At each switch browser : it force current handle+minimize+maximize

It works fine

Thanks again for your time and your help

Fabrice

---

<div class="post-metadata">

**Author:** ![Josdov](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@Josdov](https://forum.robotframework.org/u/Josdov)\
**Post date:** [26 December 2021 18:46 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/12 "2021-12-26T18:46:45Z")

</div>

Hello Everyone, Hello Fabrice  
I am new here, I am not a developer and I am having the same problem as Fabrice.  
How to modify the Keyword Switch Browser in the SeleniumLibrary in order to add your code?  
I am having the exact same problem.  
Sorry for my broken English, I am French.  
Josue

---

<div class="post-metadata">

**Author:** ![Fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@Fabrice](https://forum.robotframework.org/u/Fabrice)\
**Post date:** [4 January 2022 07:17 UTC](https://forum.robotframework.org/t/switch-browser-it-works-but-not-visible-at-screen/2180/13 "2022-01-04T07:17:57Z")

</div>

Salut Josue,

Je suis francais aussi alors on va le faire en francais…🙂  
D’abord, bonne annee !!

Ensuite, pour effectuer la modif j’ai en effet oublié de dire le fichier a editer, donc :

Tu dois editer le fichier [TonInstall]/SeleniumLibrary/Keywords/browsermanagement.py

Dans le fichier tu recherches “def switch\_browser” (c’est la fonction appellée)

Dans le “try:” en dessous de la partie doc, tu colles le code donné en dessous de la ligne “self.drivers.switch…” en respectant l’indentation

Tu sauves, tu relances

Voila, bon courage

Fabrice
