Browser automatically close when using Selenium

Hello all,
I am new to RPA Framework and I am using it for my personal projects.
I’m getting into some troubles with RPA.Browser.Selenium, I am trying to open browser and go to the web page, but the browser window just close when it finishes loading the page. I am coding in Pycharm and using the syntax of Python in my project.
Please help me, thanks a lot.
Screenshot 2021-10-29 212244

1 Like

Hi, @minhnhutlop9a2ttcc!

You can set the auto_close option to keep the browser open. This is currently an undocumented feature. :slight_smile:

Here’s an example in Robot Framework - the same option is available in Python:

*** Settings ***
Library           RPA.Browser.Selenium    auto_close=${FALSE}

*** Tasks ***
Leave the browser open
    Open Available Browser    https://developer.mozilla.org
1 Like

Hi,

I am coding in VS Studio with Robocorp extension, however the auto_close=$[{False} isn’t working. Even after setting this argument along with RPA.Browser.Selenium in Library the browser still closes. Can you please help?

After testing I’ve got the same issue: (Only with VS Code)
With VS code the browser close
With RobocorpLab the browser stay open
With rcc command the browser stay open

What rpa framework version you are using? Tried with 12.5.1 and worked as excepted in VS.

It’s the default rpa framework version 12.1.1 that got installed. However I changed it to 12.5.1 as well but still the browser closes.

I did use rpaframework==12.5.1 for my test too.

PS: I don’t know if that matter, but I’m running Linux

I might be reading this too literally, but that syntax with the square bracket is not correct. :slight_smile:

Well, mine is correct and I got the same result:

Library     RPA.Browser.Selenium    auto_close=${FALSE}

And this does work with RCC and RobocorpLab but not with VS Code

It was a typing mistake.

Library RPA.Browser.Selenium auto_close=${FALSE}

This is what I use

Then it could be related to Linux (I’m on macOS).

I use macOS, does the rpa framework version has any role in it?

Ok I’ll give it a try on windows to see what’s the behavior.

Need to check just in case: Do you have a Teardown defined somewhere? If you have one and it’s calling something like Close All Browsers, then the auto_close won’t have an effect.

I have not defined Teardown.
I have just started this and I wrote just one line of code to open browser and nothing else.
Browser opens and it closes.
Not sure what am I doing wrong here.

However I did the same thing in Robocorp Lab and the browser stays. (auto_close is not mandate for Robocorp lab anyways).

No I commented the line for the test.
And it’s working just as expected in RCC and RobocorpLab

Running out of ideas. Can you paste the full robot here?

*** Settings ***
Documentation Template robot main suite.
Library RPA.Browser.Selenium auto_close=${FALSE}

*** Tasks ***
Launch Browser
Open Available Browser RobotSpareBin Industries Inc. - Intranet
Input Text id:username maria
Input Text id:password thoushallnotpass
Submit Form

Try to use the Preformatted text when you past some code so we can see the correct spaces.

Hope the snap helps.