I am a newbie of python and I am trying to write a script that goes to Instagram, checks if logged in, if not logged in logs in with a given username and password.
The program works fine but every time I run it, it opens a different chrome window and does the work even there is already an opened chrome. Also, it does not save the logins, I run the program, it logs in Instagram, I do not logout and when I run again, with a new window of chrome, it is not logged in so I do not know much about browsers but it is like does not save or check cookies or something like that. In other words, every time chrome is acting like I just installed it.
So, how can I make it open the chrome with cookies, etc. (I did not know how to explain that but hope you understand)?
Here is how I login:
global browser
browser = webdriver.Chrome()
def LogIn():
browser.get("https://www.instagram.com/accounts/login/")
sleep(2)
username = browser.find_element_by_css_selector("input[name='username']")
password = browser.find_element_by_css_selector("input[name='password']")
sleep(3)
username.send_keys(kAdi)
password.send_keys(sifre)
loginButton = browser.find_element_by_xpath("//button[@type= 'submit']")
loginButton.click()
sleep(3)
Thanks in advance.