Selenium Library or Browser Library in Robot Framework

Hi,

I am new to Robot Framework and not able to decide which library (Selenium Library or Browser Library) to use for automating our application. Could you please suggest which is more reliable, fast and which has less cons & limitations.

This would help me a lot to start automating application at my work place.

Also is it possible to use both libraries (Selenium Library or Browser Library) within the same project (or even same test)?

Hi Ravi,

Are you trying to start a religious war? :rofl::rofl::rofl:

  • Selenium Library drives Selenium which is based on Java
  • Browser Library drives Playwright which is based on NodeJS

I have used both and found that both were more than adequate for my needs and probably for most users.
Browser Library has some obscure features out of the box that Selenium Library didn’t have however i’ve heard there are extensions for Selenium to implement them.
On the other hand Selenium Library can be installed with a simple pip install command, where as Browser Library requires you to install NodeJS first and run an initialisation script so it’s a little harder to get started.
If your AUT is NodeJS based I would say choose Browser Library, likewise of your AUT is Java based choose Selenium Library that way you’ll have developers familiar with the tech stacks if you run into issues, but otherwise I couldn’t give you a recommendation between them.

Dave.

1 Like

Selenium based on Java? That’s the first time I hear that. And what the library is based on is really not of interest. Both “talk to” the DOM of a website.

Now the Selenium ecosystem is (much) older and there’s pros and cons because of that. The browser support is much wider than PlayWright, for example. Whether or not that’s relevant depends on your organization.

PlayWright works on engines, not browsers, and thus allows testing of Webkit on Windows, while you cannot test Safari on Windows using SeleniumLibrary. Another big benefit (to me) of PlayWright testing against the (vendored) engines is that things don’t randomly break when either Selenium, a SeleniumDriver or some browser is updated.

Also something to consider is that PlayWright has a wider scope than SeleniumLibrary. SeleniumLibary only works on the DOM, by design. PlayWright also has access to the network layer, so you can access the REST calls going back and forth and you can do things like wait for no network traffic for some timeframe.

In addition, PlayWright has support for ShadowDOM and iframes, which can be of importance.

As to faster and more reliable, PlayWright is generally the better choice for those criteria, due to its in-build waiting and auctionabilty checks.

Thankyou both. Apologize for the late reply.

Quick question (I’m new to Browser Library, but not Robot Framework):

How do you get WebKit working on Windows? I’ve found that even double-clicking the binary produces a browser window, but nothing resolves so no content. Chromium and Firefox work just fine. FWIW, I’ve downloaded and installed Otter Browser and it works on Windows (if I interact with it via Windows Explorer), but even replacing the webkit-nnnn directory with all its binaries ends with the same result.

So, any tips/tricks to get a WebKit browser working on Windows?

Yes, it is possible but you’ll have some namespace collisions. Thus, a number of keywords you’ll have to prefix with Browser. or SeleniumLibrary. respectively. IMO, this is a reasonable approach if you are slowly converting your code base from Selenium to Playwright/Browser. If you change everything in a given suite, you can eliminate referencing the Selenium Library and do away with the namespace specifiers.

When I tried migrating from SeleniumLibrary to Browser;

I found it was easier to remove SeleniumLibrary, then for the selenium keywords that aren’t the same name in Browser I just wrote a wrapper keyword with the selenium keyword’s name and behaviour but built using Browser keywords. then I focused on the few places where the keywords had the same name but sightly different behaviour.

Using this approach I had all my existing tests producing the same results with browser as they did with selenium quite quickly, then I could go back test by test improving the tests by using the optimal Browser keywords for that test without loosing my ability to test the next release at short notice.

Maybe this might help you as well :crossed_fingers:t2:

Dave.

2 Likes

Great suggestion(s) Dave - thanks!

It’s been a while since I used it, but I think I just ran with WebKit as rendering engine (headless): New Browser browser=webkit and just run as normal.