I am trying to Automate a login scenario of my project. After Hitting the URL a POPUP Authentication window comes even before the page loads. If we not pass that window we can't see the home page.
the problem is once the pop-up comes i can't inspect the element using firebug,its not letting me to click anywhere else.
i tries to handle the window but still the control is not going to the username and password text box. i tried windowhandle,robot class but not working. Please anybody can help??
here is the piece of code:-
Set<String> handles = driver.getWindowHandles(); // get all window handles
System.out.println(handles.size());
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler);
also the robot class:-
Robot rb = new Robot();
//Enter user name by ctrl-v
StringSelection username = new StringSelection("myusername");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(username, null);
Thread.sleep(2000);
river.switchTo().window(mainHandle);
rb.keyPress(KeyEvent.VK_A);
rb.keyRelease(KeyEvent.VK_A);
rb.keyPress(KeyEvent.VK_M);
rb.keyRelease(KeyEvent.VK_M);
rb.keyPress(KeyEvent.VK_CONTROL);
rb.keyPress(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_CONTROL);
//tab to password entry field
rb.keyPress(KeyEvent.VK_TAB);
rb.keyRelease(KeyEvent.VK_TAB);
Thread.sleep(2000);
//Enter password by ctrl-v
StringSelection pass = new StringSelection("password");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(pass, null);
rb.keyPress(KeyEvent.VK_CONTROL);
rb.keyPress(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_CONTROL);
//press enter
rb.keyPress(KeyEvent.VK_ENTER);
rb.keyRelease(KeyEvent.VK_ENTER);
//wait
Thread.sleep(5000);