1

i have a problem with this bit of code:

from selenium import webdriver
driver = webdriver.Chrome(executable_path="E:\Hack\chromedriver_win32\chromedriver.exe")
driver.get("https://www.instagram.com/")
user_name=driver.find_element_by_xpath('//*[@id="loginForm"]/div/div[1]/div/label/input')
user_name.send_keys('user_name')

Now the problem is that the script cant find the username/pasword input fields on https://www.instagram.com/... I tried through name, class, XPath or whatever it's called but othing! It just doesnt want to work. Can anyone find a solution to this pls ? :(

  • Only issue the code can have is you are trying to identify wrong object on insta page. Else I don't see any issue. Try to get the right address of element, may be try with some other elements. Thanks :) – YamanSinghal Nov 27 '21 at 17:09

1 Answers1

1

You are probably looking for the page: https://www.instagram.com/accounts/login/

Your Xpath also doesn't seem too correct.

try on the page I sent with this one

driver.find_element_by_xpath('//input[@type="text"]')

You may come to another problem on Instagram. They have ways of detecting the Webdriver and they simply redirect you to a page where you have to perform tasks to prove you are a human and not a computer. You may need to create headers and work arounds to access the login page without many problems.