Challenges with different browsers in Selenium

The first thing you would do when you are picking to automate using Selenium WebDriver is launch a browser. Even this simple step can give you some glitches:


The most common issue is that the browser is invoked with unnecessary add-ins etc..
Simple solution:

Use the profile manager by typing the following command in run edit

"firefox.exe -p " to see all the profiles

Now use the profiling concept to avoid issues:

ProfilesIni all = new ProfilesIni ();
FirefoxProfile profile = all.getProfile("Profile Name")

WebDriver wd = new FirefoxDriver(profile);

//IE Driver

The most common issue here is that you get an error message regarding the trusted domains:
In Internet Options>>Security >>Trusted sites the Enable Protected Mode checkbox is unchecked currently. If we can check it manually the problem will be resolved.
The Reason of the issue is, the settings of IE are not as expected for Internet Explorer WebDriver API, so it can not find the HTML Document of the loaded application inside the Browser. 

Or use the below code:
 System.setProperty("", "C:\\Documents and Settings\\admin\\Desktop\\Selenium-Dump\\IEDriverServer.exe");
DesiredCapabilities capab = DesiredCapabilities.internetExplorer();
capab.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

WebDriver wd = new InternetExplorerDriver(capab);


File file =new File("C:\\Documents and Settings\\admin\\Desktop\\Selenium-Dump\\IEDriverServer.exe");
System.setProperty("", file.getAbsolutePath());
DesiredCapabilities cap= new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
cap.setCapability("initialBrowserUrl", URL);                       //  this is the solution
driver=new InternetExplorerDriver(cap);

 //Chrome Driver
System.setProperty("", "C:\\Documents and Settings\\admin\\Desktop\\Selenium-Dump\\chromedriver.exe");
 ChromeDriver cd = new ChromeDriver();

Happy Invoking :)


Popular posts from this blog

Trim / Remove spaces in Xpath?

XPATH for IE / internet explorer

Complete list of Serenity properties