0

I am using selenium to automate some test on many websites. Everytime I get the cookie wall popup.

I know I can search for the xpath of the Accept cookie button and then click on it with selenium. This solution is not convenient for me because I need to search for the button manually. I want a script that accepts cookie for all sites automatically.

What I tried to do is get a cookie jar by making a request to the website with python requests and then set the cookie in Selenium ==> Not working with many error

I found this on stackoverflow :

fp = webdriver.FirefoxProfile()                                                                                                                         
fp.set_preference("network.cookie.cookieBehavior", 2)                                                                                                   
driver = webdriver.Firefox(firefox_profile=fp, executable_path="./geckodriver")  

This worked for google.com (no accept cookie popup appeared) but it failed with facebook.com and instagram.com

rudeus123
  • 13
  • 1
  • Have you tried to follow this solution ? https://stackoverflow.com/questions/64032271/handling-accept-cookies-popup-with-selenium-in-python as the answer says, it may have to do with the delay between when the page loads and when the cookie pop up appears – Anto Aug 23 '22 at 14:15
  • The thing is in this post he knows the Xpath of the button (Accept cookie), if I choose a random website, I need to go find the Xpath of the accept cookie then put it in my code, – rudeus123 Aug 23 '22 at 14:21
  • True, my bad I was a little too quick on the duplicate flag – Anto Aug 23 '22 at 14:25

0 Answers0