0

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

enter image description here

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();
}

}

Nguyen Vu Hoang
  • 1,570
  • 14
  • 19
  • @DebanjanB Added more info. I tried the solution to put username/pwd onto URL before reaching here but it doesnot work. – Nguyen Vu Hoang Apr 05 '19 at 06:36
  • Step 3A within your question directly points to [HTTP / Basic Authentication](http://www.httpwatch.com/httpgallery/authentication/). Am I missing something? Can you update the question with what exactly you mean by **doesnot work** along with _code trials_, _error stack trace_? – undetected Selenium Apr 05 '19 at 06:40
  • Added code snipet used and update Q again. It keeps stucking at HTTP/Basic Auth popup without giving any error/exception. – Nguyen Vu Hoang Apr 05 '19 at 06:47

2 Answers2

1

create instance of DesiredCapabilities class :-

DesiredCapabilities handErr = DesiredCapabilities.chrome ()
handErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true) WebDriver driver = new ChromeDriver (handErr);

0

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

http://sikulix.com/

David Silveiro
  • 1,515
  • 1
  • 15
  • 23