in Education by
I want to log in to instagram using selenium, but I can't seem to enter values into the fields. Here's my script: #go to this address browser.get('https://www.instagram.com') #sleep for 1 seconds sleep(1) #find the 'login' button on homepage login_elem = browser.find_element_by_xpath( '//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a') #navigate to login page login_elem.click() Having trouble from here onwards: #locate the username field within the form unform = browser.find_element_by_xpath( '//*[@id="f3b8e6724a27994"]') #clear the field textunform.clear() #enter 'test' into field unform.send_keys('test') JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
There is a trick in this, instead of searching for the Button (Log In) there is a better way to log in without it. how? let's see: Import the packages you need: from selenium import webdriver from selenium.webdriver.common.keys import Keys from time import sleep #Select the driver, In our case we will use Chrome. chromedriver_path = 'chromedriver.exe' # Change this to your own chromedriver path! webdriver = webdriver.Chrome(executable_path=chromedriver_path) sleep(2) webdriver.get('https://www.instagram.com/accounts/login/?source=auth_switcher') sleep(3) username = webdriver.find_element_by_name('username') username.send_keys('yourUsername') password = webdriver.find_element_by_name('password') password.send_keys('yourPassword') #instead of searching for the Button (Log In) you can simply press enter when you already selected the password or the username input element. submit = webdriver.find_element_by_tag_name('form') submit.submit() You can copy the code and run it directly (even without a real username or password) To get the webdriver (chromedriver.exe) from ChromeDriver

Related questions

0 votes
    I have written tests with Selenium2/WebDriver and want to test if HTTP Request returns an HTTP 403 Forbidden. ... Selenium WebDriver? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    How to open a new tab in the existing Firefox browser using Selenium WebDriver (a.k.a. Selenium 2)? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I use Selenium RC, for which the scroll command is selenium.getEval("scrollBy(0, 250)"); Now, I have started ... the command for it? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I use Selenium RC, for which the scroll command is selenium.getEval("scrollBy(0, 250)"); Now, I ... questions and answers pdf, Verbal Reasoning interview questions for beginners...
asked Oct 30, 2021 in Education by JackTerrance
0 votes
    Page scroll up or down in Selenium WebDriver (Selenium 2) using java I use Selenium RC, for which the scroll command ... using Selenium WebDriver , what will be the command for it?...
asked Nov 20, 2020 in Education by Editorial Staff
0 votes
    I am using mac mojave 10.14.3, JDK 1.8, Serenity core 2.0.40 (latest) to develop my test ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I'm working on a Java Selenium-WebDriver. I added driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); ... a better way? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I want to put value using webdriver, This is the command I am using driver.findElement(By.name("name")).sendKeys(" ... way to do so ? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    What’s the use of Selenium WebDriver? 1. To run cross-browser tests 2. To automate hardware testing 3. To run UI tests 4. To run load tests...
asked Jul 11, 2021 in Technology by JackTerrance
0 votes
    My objective-c app needs to be aware if the firewall in OSX is running, so it can tell the user ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I'm currently trying to iterate through a feed of clickable items and click them one by one and also ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    Selenium doesn’t support the following programming language: 1. Python 2. C# 3. C 4. Java...
asked Jul 11, 2021 in Technology by JackTerrance
0 votes
    Adware will not come to your system if you are using Chrome. (a) True (b) False The question was ... ,Need-for-Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    How to get ASP.NET Web API to return JSON instead of XML using Chrome?...
asked Jan 11, 2021 in Technology by JackTerrance
0 votes
    I'm creating a button in Tkinter and I wanted to create rounded corners, other posts suggested using an ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
...