Reputation: 45
I'm writing some automated tests using Selenium and Java.
The page I am trying to access needs authentication, for chromeDriver I just pass the username and password on the URL like so:
http://USERNAME:[email protected]
This works fine but with PhantomJS I can't get the page to authenticate so I just end up on about:blank
I've tried adding this to the desired capabilties of the phantomJS driver instance but it still doesn't work:
desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--web-security=false", "--ignore-ssl-errors=true", "--ssl-protocol=any", "--proxy-auth=USERNAME:PASSWORD"});
Can anyone tell me how to get this working with PhantomJS?
If it matters my password does contain special characters (an @)
THE ANSWER::: I've found out the solution myself but I will leave this here for anyone else that runs into this problem.
It worked fine in ChromeDrive passing in the USERNAME:PASSWORD@DOMAIN on the URL but not in PhantomJS, I tried different way to set the --proxy-auth on the PhantomJS desired capabilties but it wasn't getting beyond the authentication screen.
The solution was simple when I give it the URL with the username and password I just had to encode the @ symbol which was part of my password so I changed @ to %40 and it works fine in ChromeDriver and PhantomJS.
I guess chromeDriver parses the URL to see where the domain start but GhostDriver must just look for the first @ and assume everything after that is the domain.
Upvotes: 1
Views: 920
Reputation: 45
THE ANSWER:::
I've found out the solution myself but I will leave this here for anyone else that runs into this problem.
It worked fine in ChromeDrive passing in the USERNAME:PASSWORD@DOMAIN on the URL but not in PhantomJS, I tried different way to set the --proxy-auth on the PhantomJS desired capabilties but it wasn't getting beyond the authentication screen.
The solution was simple when I give it the URL with the username and password I just had to encode the @ symbol which was part of my password so I changed @ to %40 and it works fine in ChromeDriver and PhantomJS.
I guess chromeDriver parses the URL to see where the domain start but GhostDriver must just look for the first @ and assume everything after that is the domain.
Upvotes: 2