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,320 points
5,833 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
18,819 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,520 points
3,822 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31 in Selenium by Sri
• 2,970 points
4,805 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 in Selenium by Sri
• 2,970 points
893 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,890 points
2,770 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
19,416 views
0 votes
1 answer