Problem with logging in to Instagram via Selenium WebDriver

Question:

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 selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.chrome.options import Options
 
option = webdriver.ChromeOptions()
option.add_experimental_option("excludeSwitches", ["enable-automation"])
option.add_experimental_option('useAutomationExtension', False)
option.add_argument("option.add_argument('--disable-blink-features=AutomationControlled')")
 
driver = webdriver.Chrome(chrome_options=option, executable_path=r'C:UsersЮзернеймDesktopchromedriver.exe')
driver.get(f'https://www.instagram.com/')
 
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']")))
user_data_name.clear()
user_data_password.clear()
user_data_name.send_keys("log")
user_data_password.send_keys("pass")
 
log_in = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[type='submit']"))).click()```
Asked By: Watyeraty

||

Answers:

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.