Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (29.3k points)

How can I auto fill the username and password over the link below:

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

chromedriver = 'C:\\chromedriver.exe'

browser = webdriver.Chrome(chromedriver)

browser.get("http:/www.example.com")

After that I really do not know:

username = Select(browser.find_element_by_name('Username'))

password = Select(browser.find_element_by_name('Password'))

username.select_by_visible_text("text")

password.select_by_visible_text("text")

1 Answer

0 votes
by (50.2k points)

You can auto-fill the credentials by following this code 

driver = webdriver.Firefox(...)  # (Or Chrome(), or Ie(), or Opera() depends on which you are working on)

username = driver.find_element_by_id("username")

password = driver.find_element_by_id("password")

username.send_keys("YourUsername")

password.send_keys("PassworD")

driver.find_element_by_name("submit").click()

For more details on select()

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s automation testing course!

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...