0

I am writing some automation tests, and the site my test needs to connect to requires a site authentication.

I'm not sure how to handle this pop-up in order to provide the username & password. If the dialogue box is closed then the site can not be reached .. e.g. unauthorised access.

I have tried using passing the credentials through the url, but that doesn't work. Any suggestions appreciated.

  • acceptance.suite.yml

    actor: AcceptanceTester modules: enabled: - WebDriver: browser: chrome url: "http://username:password@my.site.autenticated.url" - \Helper\Acceptance

With this I get Unable to parse URI: http://username:password@my.site.autenticated.url

yowza
  • 15
  • 5
  • Possible duplicate of [How to handle Pop-up in Selenium WebDriver using Java](https://stackoverflow.com/questions/19403949/how-to-handle-pop-up-in-selenium-webdriver-using-java) – timbre timbre Jul 14 '17 at 14:52
  • Can you show how u are passing credentials in url .there you can missing some thing – Ankur Singh Jul 15 '17 at 06:31
  • @AnkurSingh I have modified my question to include what I have tried – yowza Jul 15 '17 at 16:24

2 Answers2

0

Try doing this :

http://username:password@yourweburl/

example : -

driver.get("http://username:password@www.example.com/")
Rohhit
  • 722
  • 3
  • 12
  • 25
  • I have tried adding that into my acceptance suite : url config .. `url: driver.get("http://username:password@my.authenticated.site.URL")` Didn't work – yowza Jul 15 '17 at 16:27
0

This may help you :-

String Password = URLEncoder.encode("pass");

String UserName= URLEncoder.encode("UserName");

String url = String.format("http://%s:%s@xyz", UserName, Password);

In this %s is variable which pass to url in form of parameter .

You can refer this url also https://serverfault.com/questions/371907/can-you-pass-user-pass-for-http-basic-authentication-in-url-parameters

Ankur Singh
  • 1,239
  • 1
  • 8
  • 18