Selenium how to work with cookies instagram?

I want to make every test run not login again.

All cookies from instagram.com after login took, kept. Were only using the add_cookie to add them.
What and where to insert? Just cook too much
April 7th 20 at 10:45
1 answer
April 7th 20 at 10:47
Solution
Instead of an anonymous profile created by selenium by default, you can use specified custom profile that will be saved.
Do not tell another, how to work with profiles?

Here error
from selenium import webdriver
browser = webdriver.Chrome("C:\\Users\\Eugene\\Documents\\Python\\Tests\\Inst\\chromedriver.exe")

options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\Users\Eugene\AppData\Local\Google\Chrome\User Data")
wd = webdriver.Chrome(chrome_options=options)
- bria83 commented on April 7th 20 at 10:50
@bria83, your mistake is that you do not write what error occurs. - Kristopher12 commented on April 7th 20 at 10:53
Oh and slashes you nekrasovy. - Kristopher12 commented on April 7th 20 at 10:56
@Kristopher12, sorry

DevTools listening on ws://127.0.0.1:51453/devtools/browser/5d97fd79-2802-4f2f-9a20-2c221abe5432
c:/Users/Eugene/Documents/Python/Tests/Inst/instparse.py:9: DeprecationWarning: use options instead of chrome_options
wd = webdriver.Chrome(chrome_options=options)
Traceback (most recent call last):
File "C:\Users\Eugene\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Eugene\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\Eugene\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] the system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:/Users/Eugene/Documents/Python/Tests/Inst/instparse.py", line 9, in
wd = webdriver.Chrome(chrome_options=options)
File "C:\Users\Eugene\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Eugene\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'non-ie web browsers' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriv...

- bria83 commented on April 7th 20 at 10:59
@Kristopher12, slashes already screened - bria83 commented on April 7th 20 at 11:02
And that, without chrome_options=options rabotaet? Judging by the error text, options nothing to do with it. - Kristopher12 commented on April 7th 20 at 11:05
@Kristopher12, Yes, no options everything works - bria83 commented on April 7th 20 at 11:08
@bria83, then something in the path of the user-data-dir not. Maybe banal typo. Or folder no. Or all of the slashes are not escaped. Or maybe the spacebar requires additional quotes around the path. Or all the same two minuses in front of the desired parameter. Or all at once...

options.add_argument(r"user-data-dir=C:\Users\Eugene\AppData\Local\Google\Chrome\User Data")
options.add_argument('user-data-dir="C:\Users\Eugene\AppData\Local\Google\Chrome\User Data"')
options.add_argument(r"--user-data-dir=C:\Users\Eugene\AppData\Local\Google\Chrome\User Data")
- Kristopher12 commented on April 7th 20 at 11:11
Faced with a similar problem. Cookies not saved in the default folder. Pointed out to her, it worked. But: Cookies are not saved if chrome is running in headless mode, and also on systems other than Windows. - Emory commented on April 7th 20 at 11:14

Find more questions by tags PythonSelenium