# Click Button in accept cookie popup not work

**URL:** <https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322>\
**Category:** Robot Framework\
**Created:** [11 October 2025 16:18 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322 "2025-10-11T16:18:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarlosGiorgi](https://avatars.discourse-cdn.com/v4/letter/c/9de0a6/32.png) [@CarlosGiorgi](https://forum.robotframework.org/u/CarlosGiorgi)\
**Post date:** [11 October 2025 16:18 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322/1 "2025-10-11T16:18:27Z")

</div>

Good Afternoon!

I can’t close this popup in url [https://www.itau.com.br/servicos/boletos/segunda-via](https://www.itau.com.br/servicos/boletos/segunda-via)

Html

[![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/0/0d30927566169b7651170d11ae00c243f81d1dee.jpeg)](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/c/cafd63274547164f94160c7b17cf4554f8557141.png "image")

xpath: /html/body/itau-cookie-consent-banner//section/div/div[2]/div[2]/button[2]

my code:

Open Browser url=${url\_itau} browser=${BROWSER}

Wait Until Page Contains Element locator=xpath:${botao\_cookie}

Click Button locator=xpath:${botao\_cookie}

Error:

Element ‘xpath:/html/body/itau-cookie-consent-banner//section/div/div[2]/div[2]/button[2]’ did not appear in 5 seconds.

Someone please? Tks

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [11 October 2025 17:58 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322/2 "2025-10-11T17:58:28Z")

</div>

You don’t show, but the HTML code is inside a **shadow DOM**. `SeleniumLibrary` is not the best framework for this. You should try `Browser` library.

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

If you really want to use `SeleniumLibrary` then you may have to code in JavaScript or Python to call the function `getShadowRoot()`.

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [11 October 2025 23:14 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322/3 "2025-10-11T23:14:52Z")

</div>

You may like to see [this comment in LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:7382834495894384640?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7382834495894384640%2C7382875086963503104%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287382875086963503104%2Curn%3Ali%3Aactivity%3A7382834495894384640%29)

---

<div class="post-metadata">

**Author:** ![CarlosGiorgi](https://avatars.discourse-cdn.com/v4/letter/c/9de0a6/32.png) [@CarlosGiorgi](https://forum.robotframework.org/u/CarlosGiorgi)\
**Post date:** [13 October 2025 17:56 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322/4 "2025-10-13T17:56:47Z")

</div>

Thank you for your help! I used getshadowroot and it’s worked fine!

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [13 October 2025 18:05 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322/5 "2025-10-13T18:05:31Z")

</div>

Can you post here the code you use to help others?

---

<div class="post-metadata">

**Author:** ![CarlosGiorgi](https://avatars.discourse-cdn.com/v4/letter/c/9de0a6/32.png) [@CarlosGiorgi](https://forum.robotframework.org/u/CarlosGiorgi)\
**Post date:** [13 October 2025 18:34 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322/7 "2025-10-13T18:34:47Z")

</div>

**\*\*\* Test Cases \*\*\***

_ **Executar Rotina** _

Wait Until Page Contains Element dom:${campo\_cpf\_cpj}  
#Log dom:${JSPath}  
Sleep 5s  
Click Element dom:${campo\_cpf\_cpj}  
Input Text dom:${campo\_cpf\_cpj} text=${cnpj}  
Click Element dom:${campo\_dados\_boleto}

Variable

${campo\_cpf\_cpj}= document.querySelector(‘app-emissaoboletos’).shadowRoot  
… .querySelector(‘#billet\_page’)  
… .querySelector(‘#billet\_page-grid’)  
… .querySelector(‘app-billet’)  
… .querySelector(‘#billets’)  
… .querySelector(‘form’)  
… .querySelector(‘#billets-forms’)  
… .querySelector(‘#billets-forms-fields’)  
… .querySelector(‘app-input-field[formControlName=“cpf\_cnpj”]’)  
… .querySelector(‘div.billet-input\_field’)  
… .querySelector(‘div.billet-input\_field-group’)  
… .querySelector(‘#billet-input\_field-input-cpf\_cnpj’)

html:

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

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [13 October 2025 22:09 UTC](https://forum.robotframework.org/t/click-button-in-accept-cookie-popup-not-work/9322/8 "2025-10-13T22:09:00Z")

</div>

This is the version with Browser library for the original problem of accepting cookies:

```python
    ***Settings***
    Library Browser

    ***Test Cases***
    Accept Banner with Browser 
        VAR ${url_itau}= https://www.itau.com.br/servicos/boletos/segunda-via
        VAR ${elemento}= css=\#itau-cookie-consent-banner-accept-cookies-btn
        New Browser headless=False
        New Page url=${url_itau}
        Sleep 5 seconds
        Wait For Load State
        Take Screenshot
        Click ${elemento}
        Sleep 5 seconds
        Take Screenshot

```
