ils
ils

Reputation: 15

Selenium Webdriver java automate window

Could you please tell me how to automate this window using webdriver and java - https://www.screencast.com/t/Zf19fumzl1j

Upvotes: 0

Views: 73

Answers (1)

Sandipan Pramanik
Sandipan Pramanik

Reputation: 348

You can not automate the window ( for HTTP Authentication ) using selenium. You can use robot framework to automate this window. Here is the approach :

  1. Instead of putting your url like http://yoururl.com, put it like http://username:[email protected]. It will bring a confirmation dialog.

    driver.get("http://username:[email protected]");

  2. To click the confirmation dialog use following code

    import java.awt.AWTException;
    import java.awt.Robot;
    import java.awt.event.KeyEvent;
    
    public void clikOKOfConfirmationDialog(){
    try {
        Robot robot = new Robot();
        robot.delay(2000);
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
    } catch (AWTException e) {
        e.printStackTrace();
     }
    }
    

This approach might not be work with IE. Hope this will help.

Upvotes: 1

Related Questions