0

I am trying to handle authentication popup through my selenium test by passing username and password in URL.

I have tried following solutions:

  1. I have tried to send username and password in URL
  2. I have tried handling with alert, it doesn't work.
  3. I have tried solutions provided in - How to handle authentication popup with Selenium WebDriver using Java, almost all other than AutoIT, none of them worked for me

I have a Maven project, I am trying to send url with username and password from project.properties file, which looks like this -

URL = https://username:password@URL

open url code-

WebDriver driver = new ChromeDriver();

driver.navigate.to(URL);

I get below error in browser console: "there has been a problem with your fetch operation: Failed to execute 'fetch' on 'Window': Request cannot be constructed from a URL that includes credentials"

4
  • I see there is a problem in the URL URL = https//username:password@URL It should have been URL = username:password@URL You are missing ":" after https Commented Jul 17, 2019 at 4:22
  • @Raghavendra Bankapur, I missed it while posting the question, I have ":" in URL in my code. Thank you Commented Jul 17, 2019 at 18:42
  • If it is a public website, can you please paste the complete URL here? Commented Jul 18, 2019 at 3:21
  • @Raghavendra Bankapur, it is not public website. I was able to resolve the issue using AutoIT script. Thank you for the help, appreciate it. Commented Jul 18, 2019 at 16:01

1 Answer 1

1

I am able to handle this using AutoIT script. The script looks something like this,

WinWaitActive("Sign in")

Sleep(5000)

Send("username")

Send("{TAB}")

Send("password")

Send("{ENTER}")

I run this script through my code,

WebDriver driver = new ChromeDriver();

Runtime.getRuntime().exec("(path)\AutoIt\script.exe");

driver.get(prop.getProperty(URL));

driver.navigate().refresh();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.