Perform authentication using Internet Explorer or Microsoft Edge
The Windows OS authentication pop-up window is not accessible through standard Selenium tools. When using Microsoft Edge, you can use the following code based on Perfecto visual functions.
Copy
ie_edgeAuthTest(driver, "https://jigsaw.w3.org/HTTP/Basic/", "guest", "guest");
public static void ie_edgeAuthTest(RemoteWebDriver driver, String url, String username, String password) throws InterruptedException {
FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(120,TimeUnit.SECONDS)
.pollingEvery(5,TimeUnit.SECONDS)
.ignoring(Exception.class);
String indentifier = "Windows Security";
driver.executeScript("window.open('"+ url +"','_top');");
Map<String, Object> params = new HashMap<>();
params.put("content", indentifier);
wait.until(_driver -> driver.executeScript("mobile:text:find", params).equals("true"));
params.clear();
params.put("label", indentifier);
driver.executeScript("mobile:button-text:click", params);
params.clear();
params.put("label", indentifier);
params.put("text", username);
driver.executeScript("mobile:edit-text:set", params);
params.clear();
params.put("label", "Password");
params.put("ignorecase", "case");
driver.executeScript("mobile:button-text:click", params);
params.clear();
params.put("label", indentifier);
params.put("text", password);
driver.executeScript("mobile:edit-text:set", params);
params.clear();
params.put("label", "OK");
driver.executeScript("mobile:button-text:click", params);
Thread.sleep(5000);
}
Related Articles
- Perform authentication using Chrome or Firefox
- Selenium page displays when opening localhost:8080 on desktop web
See also the Perfecto Knowledgebase.