简体   繁体   中英

Unable to open webpage using selenium web driver 2.33 and firefox 22

I am using Selenium webdriver 2.33 and firefox 22 version. I am trying to open a URL using the below code.

public class RunGoogle {
    public static void main(String[] args){     
        //System.setProperty("webdriver.firefox.bin","C:\\Users\\Desktop\\Mozilla Firefox\\firefox.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
    }
}

but when i run the above program it throwed some exception saying : Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function

for which i added guava jar file and the exception is gone.

But this time it throws some other exception saying

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:89)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:79)
at org.openqa.selenium.firefox.FirefoxProfile.<init>(FirefoxProfile.java:67)
at org.openqa.selenium.firefox.FirefoxDriver.getProfile(FirefoxDriver.java:260)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:179)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)

I have also tried setting the system property to point to firefox.exe file but found "No Luck".

What is causing the problem?

It seems to be you didn't import correctly all the libraries that come with selenium, you should import also all the libraries in the lib subfolder. Did you?

Could you add the whole class you are using to run this test?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM