Migrate from selenium to browser library

Any recommendations for migration of existing custom keywords based on selenium2library to browser library

Have you seen https://www.valagroup.com/2020/11/robot-framework-browser-library/

1 Like

Nice and useful article. Thanks.

I am also migrating my project and I started first with some custom temporary keywords that would translate selenium keywords to browser keywords with one line of code, e.g. all “wait until element is…”, or “wait until page…” or “page should…” are translated to “wait for elements state”, while replacing only state, e.g.:

Wait Until Element Is Visible
[Arguments] {element} {timeout}=None
wait for elements state {element} state=visible timeout={timeout}

For click, select, input text keywords I had custom keywords anyway that would encapsulate also wait so now it is easier to migrate.

This is the first step, so that to make sure the new Browser library is working, which it did, and it is much faster. Obviously the next step, after everything is proved to work, is to replace all these temporary keywords with corresponding Browser keywords, so that the code would look cleaner and simpler.

One good advice also is to understand that all browser lib keyword already natively integrate the wait for element state, This mean that you do not need anymore to add them before doing an action on a element .
If you need to click on a button, Click “ButtonElement” will natively wait that ButtonElement is enabled, visible …
This will clean a lot your test code as for Selenium you needed to add this “wait for” everywhere