简体   繁体   中英

How to accept cookies with robot framework?

How to handle a cookie window and accpet it with robot framework? i tried to do it in this site: https://www.ibm.com/br-pt

and my code (to accept cookies):

Page should contain element  class=truste_box_overlay_border
sleep  5s
Click element  class="call"

Try using the following keyword definition

*** Keywords ***
Accept Cookies
     Wait Until Page Contains Element   ${ACCEPT_COOKIES_BUTTON}
     Click Element   ${ACCEPT_COOKIES_BUTTON}
     ${cookie_banner_closed}     Run Keyword And Return Status   Wait Until Page /*continued*/
     Does Not Contain Element   ${ACCEPT_COOKIES_BUTTON}     2s
     Run Keyword If      ${cookie_banner_closed}==False 
     Click Element   ${ACCEPT_COOKIES_BUTTON}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM