# How to close popup window with Pycharm/Selenium?

**URL:** <https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823>\
**Category:** SeleniumLibrary\
**Created:** [18 September 2024 07:25 UTC](https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823 "2024-09-18T07:25:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Minerva](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Minerva](https://forum.robotframework.org/u/Minerva)\
**Post date:** [18 September 2024 07:25 UTC](https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823/1 "2024-09-18T07:25:30Z")

</div>

Hi. Im using SeleniumLibrary and Pycharm.  
I try to open [www.zalando.com](http://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?

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/4/4fa750d2876e2795856420423f40353c9c825189.png)

This is code I use in Pycharm:

```
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  
 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/6/6f4fc2eeb9d30b7d8c7129660f21401f52438450.png)

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [18 September 2024 07:56 UTC](https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823/2 "2024-09-18T07:56:17Z")

</div>

Hi Minerva,

if you look further up in your html, you’ll see that banner is in a shadow-root (aka shadow-dom)

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/b/b99d5370c781fdca96366954ca7e5e7c405d58b4.png)

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](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Execute%20Javascript), if you absolutely have to use SeleniumLibrary, then search for SeleniumLibrary + shadow-dom.

Hope that helps,

Dave.

---

<div class="post-metadata">

**Author:** ![Minerva](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Minerva](https://forum.robotframework.org/u/Minerva)\
**Post date:** [18 September 2024 08:11 UTC](https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823/3 "2024-09-18T08:11:46Z")

</div>

Hi @damies13 and thank you for your answer.  
I’m just a beginner with these and I appreciate all the help I get 🙂

I added Browser Library…but now I dont have any Idea how to use it with this issue. Can you help me with this?

Br,  
Minerva

---

<div class="post-metadata">

**Author:** ![Minerva](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@Minerva](https://forum.robotframework.org/u/Minerva)\
**Post date:** [18 September 2024 08:44 UTC](https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823/4 "2024-09-18T08:44:12Z")

</div>

And do I need some pluging for this Browser Library?

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [18 September 2024 08:44 UTC](https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823/5 "2024-09-18T08:44:27Z")

</div>

Hi Minerva,

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:

> Note that xpath does not pierce [shadow\_roots](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM).

There’s a good tutorial here:

> **[Browser Library | ROBOT FRAMEWORK](https://docs.robotframework.org/docs/different_libraries/browser)**
>
> Robot Framework Browser library powered by Playwright. Moving browser automation to year 2021!

And the documentation for the keywords is here:  
[https://marketsquare.github.io/robotframework-browser/Browser.html#Switch%20Page](https://marketsquare.github.io/robotframework-browser/Browser.html#Switch%20Page)

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.

Dave.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [18 September 2024 08:47 UTC](https://forum.robotframework.org/t/how-to-close-popup-window-with-pycharm-selenium/7823/6 "2024-09-18T08:47:29Z")

</div>

Hi Minerva,

> [@Minerva](#):
>
> And do I need some pluging for this Browser Library?

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.

Dave.
