I'm working to pass by the cookies acceptance windows that pop up once a website is loaded. I'm trying to achieve this by using 2 solutions described here: How to save and load cookies using Python + Selenium WebDriver with my implementation below. But the privacy settings keep on popping up on consecutive visits. I'd appreciate any resolution involving webdriver that passes by cookies.
Ad 1) First, I download cookies after my manual acceptance:
driver = webdriver.Firefox()
driver.get('https://www.forbes.com/')
# click accept
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
And then I load them hoping that the website will be launched with my privacy consent:
driver = webdriver.Firefox()
driver.get('https://www.forbes.com/')
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
driver.add_cookie(cookie)
print(cookie)
# no luck in avoiding privacy settings
Ad 2) I'm adding an argument to options as described in the post linked above:
from selenium.webdriver.firefox.options import Options
fx_options = Options()
fx_options.add_argument('--user-data-dir=C:\\path\\to\\dir_where_my_cookies_file_is_saved')
driver = webdriver.Firefox(options=fx_options)
driver.get('https://www.forbes.com/')
# no luck in avoiding privacy settings