I am new in selenium with python and still in practice
selenium with python, may I how to handle two text field in alert box? I did search on Google and some pages mention to using javascriptexecutor but I don't know how's it work and xpath is not working? thank you
Blockquote
Info website: https://the-internet.herokuapp.com/basic_auth
Both username and password is admin
Here is my code below:
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions() options.add_experimental_option("detach", True) driver = webdriver.Chrome(options=options) driver.maximize_window() driver.get("https://the-internet.herokuapp.com/basic_auth")
promptAlertUsername = WebDriverWait(driver, 10).until(EC.presence_of_element_located()) promptAlertUsername.sendKeys("admin")
promptAlertPassword = WebDriverWait(driver, 10).until(EC.presence_of_element_located()) promptAlertPassword.sendKeys("admin")
time.sleep(2) driver.quit()