Zara
Zara

Reputation: 27

How can i send User name and password in Popup using selenium

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

Upvotes: 0

Views: 4895

Answers (3)

Saravanan Seenivasan
Saravanan Seenivasan

Reputation: 149

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

Upvotes: 0

TechRookie
TechRookie

Reputation: 309

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:[email protected]";
jse.executeScript("window.open('"+URL+"')");`]

Upvotes: 1

Akarsh
Akarsh

Reputation: 967

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:[email protected]/signin");

Let me know if it works for you.

Upvotes: 1

Related Questions