Input username password using Python in Selenium WebDriver

0 votes

How to insert the username and password in any login website? Below is my code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

chromedriver = 'D:\\chromedriver.exe'
page = webdriver.Chrome(chromedriver)
page.get('http://www.abc.com')
username = Select(page.find_element_by_name('username'))
password = Select(page.find_element_by_name('password'))
username.select_by_visible_text("text")
password.select_by_visible_text("text")
May 15, 2018 in Selenium by Sahiti
• 6,370 points
9,310 views

1 answer to this question.

0 votes

You can use the below code:

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

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

selenium.find_element_by_name("submit").click()
answered May 15, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

+1 vote
2 answers

Is it possible to scroll down in a webpage using selenium webdriver programmed on python?

I using next code for facebook for ...READ MORE

answered May 16, 2019 in Selenium by mslavikas@gmail.com
26,100 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,757 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,182 views
0 votes
2 answers

What is the role of TestNG & JUnit frameworks in Selenium?

TestNG and JUnit are test frameworks . it ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
2,928 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,255 views
0 votes
1 answer

How do I get current URL in Selenium Webdriver using Python?

Use current_url element. Example: print browser.current_url READ MORE

answered Aug 8, 2018 in Selenium by Meci Matt
• 9,460 points
26,043 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP