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

流过昼夜 提交于 2021-02-10 14:22:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!