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 darklord
• 6,170 points
2,524 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,420 points

Related Questions In Selenium

+1 vote
2 answers
0 votes
2 answers

How to get HTML Source of WebElement in Selenium WebDriver using Python?

You can read innerHTML attribute to get source of ...READ MORE

answered Jun 13, 2018 in Selenium by Samarpit
• 5,130 points
17,008 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

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,110 points
931 views
0 votes
1 answer
0 votes
1 answer

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

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

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
332 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,130 points
1,114 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,420 points
7,303 views
0 votes
1 answer