It should be possible to configure Open Browser keyword to not always open a new browser.
See original GitHub issueMany times, when opening browser, there is need to open only one browser. But because depending how test are executed in Robot Framework, it is hard to find a single correct place for the Open Browser
keyword. Most of the time, it is safer to run the Open Browser
keyword from multiple levels in the suite structure, which will lead to many open browsers and loss in test execution time. There are also numerous other workarounds available.
Instead of the workarounds, it would be good to implement support for the Open Browser
keyword to open browser only once. If the the Open Browser
keyword is configured to open browser only one time, it would act in same way as the Go To
keyword.
The alias
argument could act as a marker, should the existing browser be used or new one opened.
Currently if test does this:
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome | alias |
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome | alias |
It will open two browsers with same alias.
But after the change, this:
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome | alias |
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome | alias |
will open one browser. With the first Open Browser
keyword run, it will open the browser normally and navigate to the https://github.com/robotframework/SeleniumLibrary
. In the second Open Browser
keyword run, it navigate (again) to the https://github.com/robotframework/SeleniumLibrary
.
Also this:
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome | alias |
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Firefox | alias |
will open only one browser.
If different alias is used:
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome | alias1 |
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome | alias2 |
it will open two browsers.
Also if alias is not defined
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome |
| Open Browser | https://github.com/robotframework/SeleniumLibrary | Chrome |
it will open two browsers.
There is small change that someone is misusing the alias
argument and therefore this may cause problems for users. But because the problem should be easy to fix and the probability for that is quite low, implementing this is OK.
This idea is also presented in #701
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (13 by maintainers)
Top GitHub Comments
I’d say there are several good solutions:
Call the private method in ConnectionCache. But also submit an issue/PR exposing that method and then change SL to use the new method once it’s available. Some work but possibly benefits also others.
Have a separate index to alias map in SL. Easy.
Don’t return the index in the first place. I don’t see much use for them because aliases are a much better way to switch between browsers. One possibility would be returning the actual WedDriver instance instead. If that’s done,
Switch Browser
could be enhanced to allow using that when switching making the change mostly backwards compatible. Should consider making it an error to useOpen Browser
twice without an alias, though.Opened because incomplete None handling.