Reputation: 1570
I'm having an issue when doing automation development.
1 - Browsing URL 1
2 - It's automatically redirected to URL 2
3 - Having HTTP/ Basic Authentication
I had played around with for the whole days but there was no luck to bypass this popup. Tried:
i - Chrome Arguments
ii - Embedded Username/Password onto 1URL
iii - Robot
iv - switch to alert() setAuthentication/sendkeys
Appreciated your advices
PS: Think about handling it using AutoIt or Sikuli. However, I'd love to know how to handle it without using 3rd parties.
Code Snipet used
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
long startTime = System.currentTimeMillis();
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("ignore-certificate-errors");
options.setAcceptInsecureCerts(true);
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("http://username:password@URL1");
// Being redirected to URL2
// Stucked forever at HTTP/ Basic Authentication
driver.findElement(By.id("username")).sendKeys("username");
driver.findElement(By.id("password")).sendKeys("password");
driver.findElement(By.id("kc-login")).click();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.close();
}
}
Upvotes: 0
Views: 8054
Reputation: 101
create instance of DesiredCapabilities class :-
DesiredCapabilities handErr = DesiredCapabilities.chrome ()
handErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true)
WebDriver driver = new ChromeDriver (handErr);
Upvotes: 1
Reputation: 1602
Chrome no longer seems to support the ability to interact with the dialog box. Neither JS, Java or Python have the ability to easily interact at the OS level for this.
driver.get("http://username:password@URL1");
But you could use Sikuli, to do OCR image recognition and handle the popup. It's got Java support and an IDE
Upvotes: 0