Problem with logging in to Instagram via Selenium WebDriver


I faced with this problem: when the instagram account is logged in via selenium webdriver, the web driver cannot click the "Log in" button, and when you try to press this button manually an error is returned (Failed to connect to Instagram. Make sure you are connected to the Internet and try again.).

At the same time, if I try to log in to my account manually by opening Chrome again, everything works fine. I need to log in to my account once just to save cookies, when I did these actions last time, there were no such problems.

A brief course of my actions:

  1. checking the restriction from instagram to the ip address (tried via VPN)
  2. entry restrictions imposed on the Internet connection (changed the network)
  3. reinstalling chromedriver
from selenium.webdriver.common.keys import Keys
from import expected_conditions as EC
from import By
from import WebDriverWait
from import Options
option = webdriver.ChromeOptions()
option.add_experimental_option("excludeSwitches", ["enable-automation"])
option.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(chrome_options=option, executable_path=r'C:UsersЮзернеймDesktopchromedriver.exe')
user_data_name = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='username']")))
user_data_password = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='password']")))
log_in = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[type='submit']"))).click()```
Asked By: Watyeraty



It looks like you have a problem with ip addressing, try to change the addresses when you log in via proxy or VPN.

Answered By: Foggy_gigi063
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.