Reputation: 13
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());
Upvotes: 1
Views: 1708
Reputation: 2132
I believe both puppeteer and nightmare allow you to use basic authentication and even proxies. I’d give either of those a shot
Upvotes: 0
Reputation: 1516
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.
Upvotes: 0