0

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

NoAlertPresentException

enter image description here

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") 
Stas Mackarow
  • 175
  • 2
  • 5
  • 16
  • Yeah, this is not a traditional alert and `username:password@url` is the most common and straightforward way to bypass it. – alecxe Nov 09 '19 at 02:53
  • 1
    Do you know what is it then? I can't right click it or find in console to locate it using driver.FindElement, so I don't actually understand what can I do here. – Stas Mackarow Nov 09 '19 at 02:58
  • I'd focus on the DNS error and try to figure out why cannot you pass username/password via url. You could explore extension route as well: https://stackoverflow.com/a/56285073/771848 – alecxe Nov 09 '19 at 03:28
  • Extension doesn't work, it just can't see this alert x( – Stas Mackarow Nov 09 '19 at 03:57
  • You cannot get that with pure browser tech (selenium), but if you're running on Windows, you can get to it using Windows UI automation – Simon Mourier Nov 09 '19 at 09:08

1 Answers1

0

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

Dazed
  • 1,527
  • 1
  • 13
  • 25