How to automatically log in to instagram account according to Selenium 4.14 latest version?

185 views Asked by At

This is how to automatically log in to Instagram using the following codes. I'm using Selenium 4.14 and Firefox browser.

text_box = driver.find_element(by=By.NAME, value="my-text") Or driver.find_element(by=By.ID, value="email").send_keys("email") Or email_input = driver.find_element(By.NAME, "email_or_username")

1

There are 1 answers

1
Shawn On

I don't know what your real question/issue is TBH, as you have not mentioned the issue you are facing. However, am just giving you a selenium-python code to launch browser, open Instagram application and send username and password into respective text boxes. Hope this helps.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()
driver.maximize_window()
driver.get("https://www.instagram.com/")
wait = WebDriverWait(driver, 15)
# Click on Allow all cookies button
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Allow all cookies']"))).click()

# Send text to username textbox
wait.until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys("mic test 123")

# Send text to password textbox
wait.until(EC.element_to_be_clickable((By.NAME, "password"))).send_keys("mic test 456")

Result:

enter image description here