0

I'm running my Automation test scripts on saucelabs from my local setup . While accessing to my application its redirecting to authentication pop-up . I'm unable to get webelement using Inspect element . How to insert username , password and click on OK button.

    String alertMessage= driver.switchTo().alert().getText();       
        // Displaying alert message     
        System.out.println("YES:-----------"+alertMessage);
        driver.switchTo().alert().sendKeys("funsu");
        Thread.sleep(3000);
        driver.switchTo().alert().accept();

Getting error :-

   org.openqa.selenium.NoAlertPresentException: no such alert
   (Session info: MicrosoftEdge=111.0.1661.41)

enter image description here

Little bird
  • 1,106
  • 7
  • 28
  • 58
  • I don't think that is an alert. Right-click > Inspect to see which webelements to send text and a click to. – gords Mar 25 '23 at 13:45
  • As it running on Saucelab , unable to inspect element after Right click. Basically , its Authentication window being used . – Little bird Mar 25 '23 at 14:31

1 Answers1

0

BasicAuth usually opens a modal that Selenium cannot interact with. So you'll have to pass the credentials as a header or as a prefix of the URL.

You'll see lots of historic questions and answer for this problem on Stack Overflow.

Prefixing the credentials to the URL, see here https://stackoverflow.com/a/60008470/13186962 or using Sauce Connect's --auth flag https://docs.saucelabs.com/secure-connections/sauce-connect/security-authentication/#authentication-using---auth.

Opening a ticket at support@saucelabs.com is also a good resource if you have a specific Sauce Labs issue.

mdpb
  • 31
  • 1