Filling in Login Forms in Instagram Using Selenium and Webdriver (Chrome) Python Osx

Fill username and password using selenium in python

Docs: https://selenium-python.readthedocs.io/navigating.html

For versions 4.3.0 (released in June 2022) and later, calls to find_element_by_* and find_elements_by_* were removed from Selenium. You need to use the new API:

from selenium.webdriver.common.by import By

driver = webdriver.Firefox(...) # Or Chrome(), or Ie(), or Opera()

# To catch <input type="text" id="passwd" />
password = driver.find_element(By.ID, "passwd")
# To catch <input type="text" name="passwd" />
password = driver.find_element(By.NAME, "passwd")

password.send_keys("Pa55worD")

driver.find_element(By.NAME, "submit").click()

The original response, for API versions 4.2.0 or previous:

driver = webdriver.Firefox(...)  # Or Chrome(), or Ie(), or Opera()

username = driver.find_element_by_id("username")
password = driver.find_element_by_id("password")

username.send_keys("YourUsername")
password.send_keys("Pa55worD")

driver.find_element_by_name("submit").click()

A note to your code: Select() is used to act on a Select Element (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select).

Selenium click not working in Chrome

This is what i tried on my local system and it worked

from selenium.webdriver.common.by import By
from selenium import webdriver
driver = webdriver.Chrome(executable_path="D:\\cs\\chromedriver.exe")
driver.get("https://www.instagram.com/")
a=driver.find_element(By.XPATH,'//a[text() = "Log in"]')
# added this step for compatibility of scrolling to the view
driver.execute_script("return arguments[0].scrollIntoView();", a)
a.click()

Corrected the XPATH and other changes.Please note executable path should be replaced with your path.



Related Topics



Leave a reply



Submit