0 votes
1 view
in Devops and Agile by (29.9k 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 (51.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

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


Categories

...