简体   繁体   中英

How to handle “Authentication required” window in Selenium?

I need to enter Username and Password in Authentication required window in Chrome, but it's not working due to

NoAlertPresentException

在此处输入图像描述

So my software just waiting for alert to pop-up, then getting this exception and trying again in 3 seconds and it's just looping like there is no any alert at all.

driver.SwitchTo().Alert().SetAuthenticationCredentials(User,Pass);
driver.SwitchTo().Alert().Accept();

I found similar question and the only answer was to use this method, but it's not working for me too because of DNS error, seems like I can't authenticate using this.

 driver.get("http://Username:Password@SiteURL") 

You can add nuget package AutoIT and login to a windows auth box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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