Skip to content
Advertisement

Handle/Accept cookie pop-up in Selenium

I am trying to ‘accept the cookies’ on the homepage, but my code doesn’t work. I tried to get the new window handles and then identify the subsequent Xpath for the frame and Accept button but it never work.

JavaScript

Advertisement

Answer

You no need to switch frame in your case, because there is no frame present in your page. Just inspect the “Accept Cookies” and click on that.

JavaScript

Use of Switch to Frame:

https://www.browserstack.com/guide/handling-frames-in-selenium

Use of Alert:

https://www.browserstack.com/guide/alerts-and-popups-in-selenium

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement