Hi. Im using SeleniumLibrary and Pycharm.
I try to open www.zalando.com webpage and after I enter to webpage popup window appeares. I like to press this “Se on OK”- button. But I fail with this. What am I doing wrong here?
open browser https://www.zalando.com// firefox
Wait Until Element Is Visible //button[@data-testid='uc-accept-all-button'] 20s
Click Element //button[@data-testid='uc-accept-all-button']
And this is the info behind the button if I inspect it in browser
This is a bit difficult to deal with when using Selenium Library, as It’s not really supported by Selenium
How far into the test development are you?
Is switching to Browser Library an option? (it will make your life easier when dealing with shadow-root)
I’ve not used SeleniumLibrary with shadow-root myself, though I think someone on the forum managed to work around it using Execute Javascript, if you absolutely have to use SeleniumLibrary, then search for SeleniumLibrary + shadow-dom.
Browser Library is very similar to SeleniumLibrary when you use it in Robot Framework, the difference is that underneath SeleniumLibrary uses Selenium to drive the web browser, where Browser Library uses Playwright to drive the browser, and this is why Browser Library handles shadow-dom better.
It’s important to note you cant open a browser with one library and the use the keywords from the other on that browser window, so you have to go all in on one or the other.
There are some differences in the names and syntax of the keywords, but if your familiar with SeleniumLibrary, switching to Browser Library is easy.
I will note however for this case you’ll probably need a css selector as:
I believe the css equivalent of this xpath //button[@data-testid='uc-accept-all-button'] would be button[data-testid="uc-accept-all-button"].
Follow the examples in the tutorial and try to build your own tests, this is the best way to learn but If you get stuck come back to the forum and ask questions, people here are quite helpful.
It’s covered in the Tutorial I gave you a link to, yes you’ll need NodeJS to make Browser Library work, after installing NodeJS and Browser Library, you’ll need to run rfbrowser init the first time and that will set everything up for you.