TestProject Forum

Testing pages with basic authentication

I’m having trouble testing pages that use basic authentication. I tried several solutions listed on the forum and google but without success.

Tried solutions:

The basic auth addon let me pass through to the page but had its own issues (some elements not showing) which resulted in tests that failed. The tests pass when recording them since I manually input the username and password.

Anyone has any solution to this situation?

Hello @zan.hudovernik
Please try the following:

  1. Create a step called Navigate to URL with Basic Auth.
  2. Put that step as your first step in the test.
  3. Edit the test and navigate to a different URL like google, let the step navigate to the URL with the auth.

Disable the step which does the normal navigation.

Edit the test to navigate to google for example:

@ran.tzur I tried that approach but it won’t work for me.
1.I put Navigate to URL with basic auth as first step (filled in url, username, password)
2. I edited the old navigate to go to google.com
however the test keeps failing on the first step and I am getting this error:

java.util.concurrent.ExecutionException: org.openqa.selenium.InvalidArgumentException: invalid argument
(Session info: headless chrome=89.0.4389.82)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '8d7ff25c29d8', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: 
'4.19.121-linuxkit', java.version: '13-ea'
Driver info: io.testproject.java.sdk.v2.drivers.WebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 89.0.4389.82, 
chrome: {chromedriverVersion=89.0.4..., goog:chromeOptions: {debuggerAddress=localhost:..., 
javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: 
LINUX, platformName: LINUX, proxy: {proxyType=UNSPECIFIED, aut..., setWindowRect: true, 
strictFileInteractability: false, timeouts: {implicit=0.0, pageLoad=300..., 
unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, 
webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: 
f7e37ffe12eade6b2405d4f696f...}
Session ID: f7e37ffe12eade6b2405d4f696fad4e4
Caused by org.openqa.selenium.InvalidArgumentException: invalid argument
(Session info: headless chrome=89.0.4389.82)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '8d7ff25c29d8', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: 
'4.19.121-linuxkit', java.version: '13-ea'
Driver info: io.testproject.java.sdk.v2.drivers.WebDriver

I thought maybe it is my password as it is long and it has special characters like backslash and forward slash. So I tried to input password as parameter, I tried to wrap the password in single quote and double quote and triple single quote with no success.

Please could you let me know if you have any ideas?

@ran.tzur ran.tzur Update I changed password to alphanumeric and it works.

There was also no need for editing my old test or navigating to google.com. I kept my test as it is and only added navigate to basic auth as the first step.