1

I'm automation engineer i'm going to automate e-commerce site. now issue is that we are using magneto admin panel my first step to enter user and password then site will be open i'm loose to find the popup element because its a server authentications and i'm unable to inspect the element.i have attached the snapshot that particular popup kindly have a look at this image and help will be regarded Login Screen i want to enter user password with help of selenium script

enter image description here

Frits
  • 7,341
  • 10
  • 42
  • 60
Zara
  • 29
  • 1
  • 6
  • 1
    You can try using the authenticatUsing() method of Alert - https://github.com/SeleniumHQ/selenium/blob/selenium-3.3.1/java/client/src/org/openqa/selenium/Alert.java. Also have a look at - http://stackoverflow.com/questions/5672407/how-to-perform-basic-authentication-for-firefoxdriver-chromedriver-and-iedriver – Grasshopper Apr 16 '17 at 06:43

3 Answers3

1

You can provide credentials in URL itself it means we will add username and password in URL so while running script it will bypass the same.

Syntax

http://username:password@url

example :

driver.get("http://username:password@www.xyz.com/signin");

Let me know if it works for you.

Akarsh
  • 967
  • 5
  • 9
1

The given solutions are obsolete now, I was also stuck here for a long time. It's because of Chrome driver will not allow such authentication techniques after the update 59 (probably). There are still backdoors via Selenium using the JavaScript engine in the browser to load such URLs.

driver.get("https://www.google.com");
JavascriptExecutor jse = (JavascriptExecutor) driver;
URL = "https://username:password@www.example.com";
jse.executeScript("window.open('"+URL+"')");`]
TechRookie
  • 171
  • 2
  • 4
0

From selenium 4.0.0 supports Register Basic Auth and Its using the BiDirectional API and currently only supports chromium based browsers

WebDriver driver = new ChromeDriver();
Predicate<URI> uriPredicate = uri -> uri.getHost().contains("your-domain.com");
((HasAuthentication) driver).register(uriPredicate, 
                                 UsernameAndPassword.of("admin", "password"));
driver.get("https://your-domain.com/login");

let me know if it works refer here