Playwright or Browser library

Hello,
In my application, ShadowDOM elements are used, so finding it it difficult to identify using selenium library, so was exploring some other tools which supports ShadowDOM and i found that Browser library with Robot framework and playwright supports shadowDOM. My question is as Browser library is powered by Playwright, so should i use playwright directly or browser library has all the features supported by playwright. Your responses would really help me finalizing the tool.

Thanks,
Santy

1 Like

Hi Santy,

Browser Library is a wrapper around playwright, so by using Browser Library you are using playwright.

Actually many of the Robot Framework Libraries are wrappers around the underlying tech, this is actually a good thing as you don’t need to learn so many languages, you just need to learn the Robot Framework syntax/approach, but an extra benefit is you can also easily combine tools that wouldn’t normally be easy to combine so by using Robot Framework’s Libraries you can get that extra benefit.

Dave.

1 Like

Thanks Dave, your inputs gave me insight about leveraging the capabilities of Robot framework by using different libraries. I think its better to use BROWSER library with Robot framework over Playwright.

1 Like

It helps me to decide as well. BTW, I would like to ask a similar question:

The syntax of Playwright differs from Browser library, are there some good sites so that I can see the differences? For example, if someone has good knowledge of Playwright, can he/she easily use Browser library instead? or vice versa? Thanks

Hi Ming,

The differences probably come from the difference in syntactical style of robot framework vs a programming language.

Robot Framework is designed to read like a test case that a manual tester would write for another manual tester to follow, it’s not perfect at this goal but it’s exceptionally close compared to any other automation tool i’ve used, even the tools I previously developed to achieve a similar goal didn’t come close, so I dropped what I had built and switched to Robot Framework when I found it (I have no shame in admitting someone else did a better job than me).

I’m not sure what language Playwright, Javascript I guess based on it’s dependancy on Node.js, but programming languages are not designed to be easy for humans to read but rather easy for computers to interperate while being “easy enough” for programmers to read.

The list of available Browser keywords are here.

Start out by writing the steps you want to achieve in plain English bullet points, then find the keyword that most closely matches what you wrote, bear in mind for some of the validation steps the keywords from the BuiltIn Library or another Library might be more relevant than the ones in Browser Library, and thats ok, use those, this is the real power of Robot Framework

Once you get familiar with the keywords that are in the library you’ll start using them without having to look them up, it comes naturally surprisingly quickly.

Another tip, you can write your own keywords in any language you like, so you can build your own library of keywords in your preferred language (中國 ?) that simply wrap the keywords you use often, if your project team all speak the same language this might be the test cases easier or more comfortable for your team, Of course if you’re in an English speaking or a multinational company then it’s probably best to stick to the original keywords.

Dave.

1 Like

Hi Dave,
Thank you very much for your tips! Do you have a few useful sites for Robot Framework (advanced) examples of UI and API testing, with or without using Browser Library?

Does anyone have a mapping developed between Selenium Library Keyword and Browser Library keyword. e.g. In selenium library its “Input Text”, for same action “Fill Text” is used in Browser library.

Hi Ming,

Nothing specifically however you’re welcome to study the TestDataTable test cases there are REST API and browser (SeleniumLibrary and Browser Library) test cases for the TestDataTable application.

Again nothing specific, however with the Browser Library test cases I kinda cheated and created wrapper functions with the Selenium Library keyword names and the equivalent Browser Library syntax, so you’re welcome to use these as a staring point.

Dave.

2 Likes

Thanks Dave, it will surely help me to start with, will also try to create a wrapper with some the selenium keywords i have used.

1 Like

I am trying to click the button inside the shadow-root. I tried browser library and Angular library. Nothing seems to be working. Its not identifying the locator at all

This is my locator //button[@id = ‘undefined’]