Tuesday 16 February 2016

Windows authentication in selenium

Windows authentication in selenium:
=============================
We can handle window authentication in 2 ways
1.Using selenium webdriver
2.Using Autoit tool

1.Using selenium webdriver:
----------------------------
Syntax
http://username:password@url
------------------------------
Example :
http://selenium:realtime@www.someurl.com


//sample example code:

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

public class BrowserAuthDemo {

public static void main(String[] args) throws InterruptedException {

WebDriver d = new FirefoxDriver();

d.manage().window().maximize();

d.manage().deleteAllCookies();

d.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);

d.get("http://selenium:realtime@www.engprod-charter.net/");

Thread.sleep(3000);

d.quit();
}

}

No comments:

Post a Comment