How to pass HTTP Basic Authentication in XLT Chrome Driver


#1

My purpose is to automate Google Chrome Browser

How to initialize the XLTChromeDriver ?
I have done via this way.

driver = new XltChromeDriver();

And I passed driver instance super() of noarg constructor. But chrome browser is not getting automated.

public class TestClass extends AbstractWebDriverScriptTestCase {

   public TestClass()
   {
     super(driver);
   }
  1. I have added authentication credentials in default.properties

    com.xceptance.xlt.auth.userName = username
    com.xceptance.xlt.auth.password = password

HTTP Basic Authenticaiton works fine for XLTDriver
But its not working for XLTChromeDriver

  1. Also I have pointed the browser settings in browser.properties too

    xlt.webDriver.chrome.pathToDriverServer = D:/myproject/chromedriver_win32/chromedriver.exe
    xlt.webDriver.chrome.pathToBrowser = C:/Program Files (x86)/Google/Chrome/Application/chrome.exe

But these browser.properties file mapping is not taken as that XltChromeDriver is missing system properties. Hence i passed these 2 attributes via System.setProperty() in a function and called it @BeforeClass static method to execute before @Test and NoArg Constructor

public static WebDriver getXLTChromeWebDriver(){
	capabilities = DesiredCapabilities.chrome();
        System.setProperty("webdriver.chrome.bin", "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
        System.setProperty("webdriver.chrome.driver", "D:/myproject/chromedriver_win32/chromedriver.exe");
	driver = new XltChromeDriver(capabilities);
	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	return driver;
}

and called this function in static block so tat i can pass the instance in super()

@BeforeClass	
 public static void initSetup(){
          driver = BrowserDriver.getXLTChromeWebDriver();
      baseurl = "www.myAuthenticationURL.com";
  }

Now the browser is coming. But the Authentication window is still showing. How to resolve this ?
The XLTChromeDriver mappings in browser.properties is not taken i guess.

Any advice is appreciative


#2

Hi Titus,

The properties

com.xceptance.xlt.auth.userName = username
com.xceptance.xlt.auth.password = password

apply to XLT’s browser emulation via HtmlUnit only and thus also work for XltDriver.

In contrast to XltDriver, XltChromeDriver is a standard ChromeDriver enhanced to run with our extension to measure client performance. As it uses a real browser, we can’t customize it the same way as we can do with HtmlUnit.

The only way to pass authentication credentials to a real browser is to encode them directly into the URL:

https://username:password@system.undertest.com

Thanks,
H