问题
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
回答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.
回答2:
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+"')");`]
回答3:
You can try using below:
Alert alert = driver.switchTo().alert();
alert.authenticateUsing(new UsernameAndPassword("yourUsername","yourPassword"));
来源:https://stackoverflow.com/questions/43434362/how-can-i-send-user-name-and-password-in-popup-using-selenium