简体   繁体   English

使用Selenium Webdriver进行多重身份验证

[英]Multiple Authentication with Selenium webdriver

I am using selenium webdriver to access a website. 我正在使用Selenium WebDriver访问网站。 driver.get(" http://user:password@samplewebsite "); driver.get(“ http:// user:password @ samplewebsite ”);

Two authentications are required for accessing the site. 访问该站点需要两个身份验证。 First authentication works since I have given user:password@samplewebsite 自从我给用户提供密码后,首次身份验证就可以工作:password @ samplewebsite

But the second authentication popup is for another site. 但是第二个身份验证弹出窗口用于另一个站点。 eg: https://samplesite2 例如: https:// samplesite2

How to handle this multiple authentication problem. 如何处理此多重身份验证问题。

Could someone let me know whether there is any solution for such issues. 有人可以让我知道是否有解决此类问题的方法。

Did you try with alert.authenticateUsing() method in Alert. 您是否尝试过Alert中的alert.authenticateUsing()方法。 I hope it may help you. 希望对您有帮助。

You may see the link below too: 您可能还会看到以下链接:

Webdriver - HTTP authentication dialog Webdriver-HTTP验证对话框

For my solution, if there are two authentications. 对于我的解决方案,如果有两个身份验证。

Authenticate the second one first. 首先验证第二个。

driver.get("http://user:password@samplewebsite2");

Then call the required url. 然后调用所需的URL。

driver.get("http://user:password@samplewebsite1");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM