1
votes

I want to use a headless browser to test a website in an internal network. The site makes use of basic authentication rather than a login page though so I've thus far been using something like https://username:[email protected] to access the site with my scripts.

I tried looking but is there any headless browser that supports using something like that as a URL?

I'm currently using HtmlUnitDriver with Selenium but it appears to not be working. When using the Firefox Driver, I'm able to log in just fine but I'm apparently getting 401 - Unauthorized: Access is denied due to invalid credentials when I try using HtmlUnitDriver.

For reference, I'm just using a simple driver.get(url) to open the page.

HtmlUnitDriver driver = new HtmlUnitDriver();
String url = "https://"+ uName + ":" + uPassword + "@" + testEnvironment;
driver.get(url);
System.out.println(driver.getTitle());
2
Do you have any github repo to look for this issue and reproduce it?juan garcia
I'm afraid I don't. I did edit my question to show what I'm roughly using though for whatever that's worth.pirphesdercia
may you print the url System.out.println(driver.get(url)); to see it ?Mesut GUNES
They contain my company username and password as well as the url for an internal resource so I can't post the exact thing. What it looks like though is generally https://username:[email protected]pirphesdercia

2 Answers

0
votes

I made this boiler plate for headless browser testing, it actually uses istanbul for coverage, coverall, and karma with karma saucelabs.

https://github.com/jotaoncode/web-istanbul

But it is using javascript Ecma5 not 6 if you are using Ecma6 you need to go for babelify too. As headless browser it is using PhantomJs2. This is the compatiblity table for PhantomJS2

http://kangax.github.io/compat-table/es5/#phantom

I need more info about the issue in order to reproduce the case.

0
votes

I believe both puppeteer and nightmare allow you to use basic authentication and even proxies. I’d give either of those a shot