lundi 31 décembre 2018

Send keys for 2 fields using tab option in one command line

I'm trying to automate a web page that requires to enter credentials to navigate to the page, so when enter the URL, a windows security window appear to enter user name and password then click on ok. I've tried the following code to enter the credentials, but is fills the value "username\tPassword" in the user name only without tab to the next field to enter the password (I'm using \t to switch to the password field) how can I solve this problem?

public static void main(String[] args) {

System.setProperty("webdriver.ie.driver", "C:\Users\demah\Desktop\Selenium\IEDriver\IEDriverServer.exe");

    WebDriver driver= new InternetExplorerDriver();
    driver.get("URL");
    driver.findElement(By.id("overridelink")).click();

    Alert obj = driver.switchTo().alert(); 
    obj.sendKeys("username\tPassword");
    obj.accept(); 

Aucun commentaire:

Enregistrer un commentaire