Tuesday, 4 August 2015

How to handle browser authentication in Selenium Webdriver using Java?.

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class AuthinticationRequired {

    public static void main(String[] a) {

     // Initialize driver
         WebDriver driver = new FirefoxDriver();
  
      //Maximize browser window
      driver.manage().window().maximize();
  
  //driver.get("http://Username:Password@domain_name");
            //Go to URL
        driver.get("http://dipil:bangla@localhost:4040");
 
  //Set selenium webdriver get timeout
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);     

       // Browser close
        driver.close();

    }
}

No comments:

Post a Comment