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();
}
}
How to handle browser authentication in Selenium Webdriver using Java?.
Subscribe to:
Post Comments (Atom)
this logic is not working for me
ReplyDeleteHi Ravi Teja,
DeleteIt's depend on which type of authentication use for server and same code don't work for different authentication. It nice work for me.
This Syntax :
ReplyDeletedriver.get("http://Username:Password@domain_name");
wouldn't work if the Password Consists @ symbol.
For Ex :
driver.get("http://dipil:ban@1gla@localhost:4040");
The URL is considered from the first @ symbol. and throws an error.
Could you suggest a solution for this??