import org.openqa.selenium.Alert;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
// Switch to alert window.
Alert authenticationWindow = driver.switchTo().alert();
// Type the username/email.
authenticationWindow.sendKeys("<username/email address>");
// Shift cursor focus to password input text field.
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_TAB);
// Type the password in password field. [ Selenium does not know at this point that the cursor focus is shifted, so calling Alert class instance sendKeys() will cause password to be typed in username field. So, we are copying the password first to windows clipboard and then pasting it directly into the password field using Robot class instance ]
StringSelection stringSelection = new StringSelection("<user password>");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection,null); robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
// Accept the authentication window.
robot.keyPress(KeyEvent.VK_ENTER);
Saturday, May 3, 2014
Handle Sharepoint HTTP basic window authentication - using selenium webdriver java
Subscribe to:
Posts (Atom)
AWS Certified Solutions Architect Associate - AWS Introduction - Questions
All the Best !!! Show Result !! Try Again !! ×
-
All the Best !!! Show Result !! Try Again !! ×
-
In my post i have used mailserver.com just for example you need to use an real time mail server for yourself. Why not try on your org ema...
-
Today, i am gonna describe a solution to send the Jenkins email notification with editable subject instead of default subject each time de...