0
votes

I m pretty new to both Java and Selenium, and i was trying a program to get Firefox up and running using a Webdriver. Here's the code i used

    package testPackage1;
    import java.util.List;
    import org.openqa.selenium.*;
    import org.openqa.selenium.firefox.*;
    import org.openqa.selenium.htmlunit.HtmlUnitDriver;

    public class FirefoxAutomationTest {

      public static void main(String[] args){

          WebDriver driver = new FirefoxDriver();
          driver.get("http://www.google.com");

          }
     }

All this does is open and close the firefox window, it does not load google, and it throws a UnreachableBrowserException. However when i used HtmlUnitDriver instead of FirefoxDriver, everything seems to be working fine. Am I doing something wrong here, or is this a common issue with Selenium? How do i fix this?

EDIT: List of dependencies i have added:

  • selenium-api-2.35.0.jar
  • selenium-java-2.35.0.jar
  • selenium-server-2.35.0.jar
  • selenium-server-standalone-2.35.0.jar
  • selenium-firefox-driver-2.35.0.jar

UPDATE: Been trying a lot of things to get this working, and it seems i can open html pages which are saved on my hard disk, but the browser quits itself even if i m not explicitly specifying driver.close() or driver.quit(). Nothing is shown on the console, so i guess i am safe to assume that it doesn't throw any error. Also, I guess the webDriver produces a webpage with the following info before quitting:

XML Parsing Error: undefined entity
Location: chrome://browser/content/browser.xul
Line Number 36, Column 1:<window id="main-window"
^

Now i tried the url shown on the above, and it leads to some part of the firefox interface. What's going on?

2
But I'm currently running Firefox 17.0.9, I guess that issue is caused only due to Firefox 22. am i right? - user2830110
How do i check the Webdriver version? I am currently using selenium-server-standalone-2.35.0, if that is of any help - user2830110
Ok. That's correct. Also, are you using the following jar file ? selenium-java-2.35.0.jar - Hemanth
Yes, i m using the mentioned file too. - user2830110

2 Answers

0
votes

I'm flabbergasted why this wouldn't be working. The FirefoxDriver is actually bundled with the Selenium API by default, so if you are including selenium-java-2.35.0.jar and selenium-api-2.35.0.jar I'm not entirely sure what's happening.

Once more, make sure you have..

  • selenium-java-2.35.0.jar
  • selenium-api-2.35.0.jar

And if including these don't work, then include the firefox driver manually.

  • selenium-firefox-driver-2.35.0.jar

Mind you that all of these libraries need to be included in your build path somehow. As external jar dependencies, or maven dependencies, whichever you are working with.

0
votes

Any specific requirement to use HtmlUnitDriver?

Solution :

  • Add all .jar which are included in dependancies
  • Check their paths are valid and correct in build_path
  • Verify firefox compatibility with your selenium version [Might needs to upgrade or degrade any of the component]
  • Make sure you have latest java version installed and currently pointed correctly
  • Remove proxies from your machine
  • Connect to open network for using internet
  • Add implicit wait to wait till page get loaded completely

It should solve your issue, Give a try!