# Accept cookie pop up

**URL:** <https://forum.robotframework.org/t/accept-cookie-pop-up/3127>\
**Category:** Robot Framework\
**Created:** [21 January 2022 09:42 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127 "2022-01-21T09:42:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [21 January 2022 09:42 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/1 "2022-01-21T09:42:14Z")

</div>

Hello, i got this accept pop up and I am not able to to use the click element to accept and move on with the test case.

Any help please.

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

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [21 January 2022 10:57 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/2 "2022-01-21T10:57:11Z")

</div>

Hi! Is that a public website? If so, please provide a link. If not, can you paste the HTML markup?

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [21 January 2022 12:10 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/3 "2022-01-21T12:10:52Z")

</div>

Hi, yes it is a public site [https://hub.knime.com/](https://hub.knime.com/)

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [21 January 2022 12:15 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/4 "2022-01-21T12:15:22Z")

</div>

Thanks! This works for me:

```python
***Settings***
Library RPA.Browser.Selenium

***Tasks***
Accept cookies
    Open Available Browser https://hub.knime.com/
    Click Element When Visible css=.accept-button

```

The example uses [RPA.Browser.Selenium](https://robocorp.com/docs/libraries/rpa-framework/rpa-browser-selenium) but the same should work with plain SeleniumLibrary using [Wait Until Element Is Visible](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Wait%20Until%20Element%20Is%20Visible).

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [21 January 2022 12:20 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/5 "2022-01-21T12:20:20Z")

</div>

I am getting the below error:  
No keyword with name ‘Click Element When Visible’ found.

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [21 January 2022 12:21 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/6 "2022-01-21T12:21:36Z")

</div>

The example uses a different library, see above. 🙂

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [21 January 2022 12:27 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/7 "2022-01-21T12:27:38Z")

</div>

> [@janipalsamaki](#):
>
> `RPA.Browser.Selenium`

Then I have an other newbie question. I did search for that library in Pycharm but could not find it.

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [21 January 2022 12:28 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/8 "2022-01-21T12:28:55Z")

</div>

> [@janipalsamaki](#):
>
> the same should work with plain SeleniumLibrary using [Wait Until Element Is Visible](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Wait%20Until%20Element%20Is%20Visible).

Hi! Tried to mention in the original that you can do the same with SeleniumLibrary. You probably missed that. 🙂

- Wait
- Click
- Profit!

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [21 January 2022 12:47 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/9 "2022-01-21T12:47:00Z")

</div>

> [@janipalsamaki](#):
>
> `Click Element When Visible`

That worked thanks a lot :slight\_smile. How do you extract the CSS?

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [21 January 2022 12:50 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/10 "2022-01-21T12:50:17Z")

</div>

> [@MikeCBIC](#):
>
> How do you extract the CSS?

Short answer: browser inspector tools

This article explains the topic in more detail: [How to find user interface elements using locators in web applications | Robocorp documentation](https://robocorp.com/docs/development-guide/browser/how-to-find-user-interface-elements-using-locators-in-web-applications)

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [21 January 2022 14:08 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/11 "2022-01-21T14:08:54Z")

</div>

That was very useful thanks again. I have now stuck again with the username and password fields ☹

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [24 January 2022 10:45 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/12 "2022-01-24T10:45:48Z")

</div>

How are you stuck? What have you tried?

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [24 January 2022 12:44 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/13 "2022-01-24T12:44:37Z")

</div>

I was able to clear that after few tries.  
I need to handle an or situation. Like if the first one does not work try the other one type of stuff.

1. seleniumlibrary.click element css:#\_\_layout \> div \> div.sticky-footer \> main \> section \> div \> div.grid-item-9.child-container \> div \> div \> ul \> li:nth-child(10) \> div \> div \> button:nth-child(1)
2. seleniumlibrary.click element css:#\_\_layout \> div \> div.sticky-footer \> main \> section \> div \> div.grid-item-9.child-container \> di  
any thought?

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [24 January 2022 14:14 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/14 "2022-01-24T14:14:26Z")

</div>

> [@MikeCBIC](#):
>
> element css:#\_\_layout \> div \> div.sticky-footer \> main \> section \> div \> div.grid-item-9.child-container \> div \> div \> ul \> li:nth-child(10) \> div \> div \> button:nth-child(1)

Just as a side note - there’s probably a CSS class or a UI element text you can target. The current selector would break quite easily if the HTML structure changes even a bit. I warmly recommend finding a shorter way to point to whatever element you are pointing to.

Regarding the “or” question: You have a few options.

```robot
Run Keyword And Ignore Error Click some-selector
Run Keyword And Ignore Error Click another-selector

```

That will try and click both and ignore any errors. They don’t care if something fails. The end result should be that if either succeeds, you can then proceed with the script.

Another option is to check if the elements exist before clicking and only clicking if they do exist.

What is your use case here?

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [24 January 2022 14:28 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/15 "2022-01-24T14:28:57Z")

</div>

I am using the css but the space keep moving as I had work flow so it work once and then failed because the element has moved.

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [24 January 2022 14:36 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/16 "2022-01-24T14:36:25Z")

</div>

Is that element behind the login? If not, I could give it a try.

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [24 January 2022 14:37 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/17 "2022-01-24T14:37:05Z")

</div>

Yes it is after login ☹

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [24 January 2022 14:40 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/18 "2022-01-24T14:40:56Z")

</div>

Well, I’m a member now! 😃 Can you tell what you were trying to do and with what elements?

---

<div class="post-metadata">

**Author:** ![MikeCBIC](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@MikeCBIC](https://forum.robotframework.org/u/MikeCBIC)\
**Post date:** [24 January 2022 14:48 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/19 "2022-01-24T14:48:50Z")

</div>

Thank you 🙂  
this keeps moving as I create new spaces so first time test pass but then after it does fail because it as moved.  
 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/e/e745c39dbdf5cbdc892b1c1bcea4d3d54f6ffa8b.png)

---

<div class="post-metadata">

**Author:** ![janipalsamaki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/janipalsamaki/32/154_2.png) [@janipalsamaki](https://forum.robotframework.org/u/janipalsamaki)\
**Post date:** [24 January 2022 14:54 UTC](https://forum.robotframework.org/t/accept-cookie-pop-up/3127/20 "2022-01-24T14:54:04Z")

</div>

I have no idea about this application. What are spaces and where do I create them? If you can point me there, then I might be able to help with the elements.

[Next page](https://forum.robotframework.org/t/accept-cookie-pop-up/3127.md?page=2)
