What are the different ways of handling authentication popup window using Selenium

0 votes
What are the different ways of handling authentication popup window using Selenium?
May 28, 2019 in Selenium by Pragati
11,273 views

1 answer to this question.

0 votes

Hey Pragati, authentication popups can be handled in 3 different ways:

  1. By passing user credentials in URL: Append your username and password with the URL. Syntax is: http://Username:Password@SiteURL; For eg:
    • String URL = "http://" + abha_r + ":" + myPassword + "@" + www.prime.amazon.com;
      driver.get(URL);
      Alert alert = driver.switchTo().alert();
      alert.accept();
  2. By using AutoIT: Use AutoIT script to send username and password. For eg:

    • public static void login(String email, String password) throws Exception{
      
      driver.get(URL);
      WinWaitActivate("Authentication Required","")
      Send("abha_r{TAB}myPassword{ENTER}")
      
      Runtime.getRuntime().exec("C:\\Download\\AutoItFiles\\ExecutableFiles\\FirefoxBrowser.exe");
      driver.findElement
      
      loginpage.setEmail(email);
      loginpage.setPassword(password);
      loginpage.clickOnLogin();
      }
       
  3. By using Alerts in Selenium: We can use following lines of code to handle popup window using Alerts. For eg:

    • driver.switchTo().alert();
      
      //Selenium-WebDriver Java Code for entering Username & Password as below:
      
      driver.findElement(By.id("userID")).sendKeys("userName");
      driver.findElement(By.id("password")).sendKeys("myPassword");
      driver.switchTo().alert().accept();
      driver.switchTo().defaultContent();
answered May 28, 2019 by Abha
• 28,000 points
Show us that this works.  AutoIt claims that they do not interact with browser controls (Authentication Required) is a firefox dialog.  ?
What's your query though?
Hi, how can i simply ignore this pop up without entering credentials and move to next page? Help me on this
Hey have you tried @Abha's solution?

Related Questions In Selenium

0 votes
3 answers

What are the different ways to select an option from a dropdown using Selenium Webdriver?

So follow this steps for solution: First click ...READ MORE

answered Dec 15, 2020 in Selenium by Roshni
• 10,400 points
15,484 views
0 votes
1 answer

What are the different components of Selenium?

Selenium is a testing tool and comprises ...READ MORE

answered Jan 7, 2019 in Selenium by Fuji
552 views
0 votes
2 answers

What are the benefits of using TestNG with Selenium?

Hi Falguni, some of the benefits of ...READ MORE

answered May 31, 2019 in Selenium by Anvi
• 14,110 points
385 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
4,377 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,010 points
5,290 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
3,165 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,010 points
3,690 views
0 votes
1 answer

What are locators in Selenium and what are the different types of it?

Hi Divya, in Selenium Locators define an ...READ MORE

answered May 7, 2019 in Selenium by Abha
• 28,000 points
627 views
0 votes
1 answer

What are the main disadvantages of using implicit wait in Selenium?

Hey Aaron, the main disadvantage of implicit ...READ MORE

answered May 31, 2019 in Selenium by Abha
• 28,000 points
1,461 views