Create And Run First Webdriver Script With Eclipse

Run First Webdriver Script
You need to install webdriver with eclipse to run your script in webdriver. Before running your first selenium webdriver test, you also need to download geckodriver to run your test in mozilla firefox browser. steps to download geckodriver are as below.

Download geckodriver

  • Go to geckodriver download page.
  • On geckodriver download page, you will find latest version release of geckodriver.
  • Download geckodriver win64 version if you are working with windows 64 bit system.as shown in below image.
download geckodriver
  • You will get zip file of geckodriver.
  • Extract it. You will geckodriver.exe from extracted folder.
  • Copy and paste it at D:Selenium Files (Selenium Files folder in D: drive).

After downloading geckodriver exe and installation of webdriver software testing tool, You need to write a java code in eclipse for your test case of software web application. Let me give you one simple example of creating simple webdriver script for software web application. First of all you need to create the package called “Testing_Pack” under your project and then create new class file ‘mytestclass.java’ under that package. Now copy-paste bellow given code In your ‘mytestclass.java’ file.

package Testing_Pack;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class mytestclass {

 public static void main(String[] args) {
  //set geckodriver path.
  System.setProperty("webdriver.gecko.driver","D:\Selenium Files\geckodriver.exe");
  //initialize firefox driver object to open firefox browser.
    WebDriver driver = new FirefoxDriver();
    //open URL in browser.
    driver.get("http://only-testing-blog.blogspot.com");
    String i = driver.getCurrentUrl();
    System.out.println(i);
    driver.close();
   }
}

Now you are ready to run your script from Run menu as shown bellow.

Script Explanation
Above script will 
  • open Firefox browser. 
  • Then driver.get syntax will open ‘http://only-testing-blog.blogspot.com/’ software application in firefox browser.
  • Then driver.getCurrentUrl() will get the current page URL and it will be stored in variable ‘i’. You can do same thing using “storeLocation” command in selenium IDE
  • And at last, it will print value of variable in console as shown bellow.
So this is the simple webdriver script example. You can create it for your own software web application too by replacing URL in above script. We will learn more scripts in detail in my upcoming posts.

VIEW MORE TUTORIALS ON WEBDRIVER

74 thoughts on “Create And Run First Webdriver Script With Eclipse

  1. Hi,

    I am completely new to selenium.While trying to run the , I am getting the below information in console.

    Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
    at mytestpack.mytestclass.main(mytestclass.java:10)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    … 1 more

    Please help.

  2. Very Helpful.
    I have a question thought. I have used selenium ide for a test case but i had to move to selenium webdriver in order to catch some errors/exceptions.
    I have also used flow control but in exported file from ide i get this: // //ERROR: Caught exception [unknown command [gotoIf]]
    How can i export ide test case as it is without having to write the case again?

  3. Hi Guys,

    After writing the code and if i run , i get below error

    Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:"C:Program FilesHPUnified Functional Testingbinjava_sharedclasses";"C:Program FilesHPUnified Functional Testingbinjava_sharedclassesjasmine.jar"

    Does anybody has any idea what going on in this..

    Thanks & Regards,
    Raghavendra J

  4. Hi!
    The post was really usefull and easy to understand. I followed the above steps, but i received the following exception in the console.
    "org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms."

    Could you explain how to rectify

  5. Hi!
    The blog was really useful and easy to understand but i get an error after the webdriver is launched.

    "org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms."

    Could you explain whats the reason??

    Thanks in advance,
    Vijay.R

  6. The post was really usefull and easy to understand. I followed the above steps, but i received the following exception in the console.

  7. Oi eu gostaria muito de receber o arquivo de código de amostra conforme indicado no seu texto. E parabéns estou fazendo o tutorial webdriver farei o IDE, e estou gostando muito.

  8. It would be helpful to all if the blog admin could clear the doubts on errors posted here in this section. Anyone who comes across such errors will know what to do.

  9. Thanks for your post. It's very helpful,
    But i am getting this error Please help me …

    org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    *** LOG addons.manager: Application has been upgraded

  10. Hi, I'm new to Selenium. I have tried the above program and also added selenium-server-standalone-2.410 jar in external jar library but I'm still getting the below error.

    java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver (Unsupported major.minor version 50.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Exception in thread "main"

    Pls. let me know if anything is missed out.

    Thanks,

  11. Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
    at com.google.common.base.Preconditions.checkState(Preconditions.java:177)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:106)
    at mytestpack.mytestclass.main(mytestclass.java:8)

    i am facing this issue can you pleae help on this please

  12. Hi ,

    I am new to selenium , I am getting the below error when I executed my first script

    A pop up with "could not find the main class"

    java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main"

    The program is as below

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;

    public class wiki_project
    {
    public static void main(String[] args)
    {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://google.com");
    System.out.println(driver.getTitle());
    driver.close();
    }
    }

    versions :
    Java : 1.5
    FireFox:29.0.1

  13. My code is as below

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;

    public class wiki_project
    {
    public static void main(String[] args)
    {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://google.com");
    System.out.println(driver.getTitle());
    driver.close();
    }
    }

    and verision are

    JAVA : 1.5
    Firefox:29.0.1

  14. I have copied your code and I am getting following error message..not sure what is the problem

    Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA
    Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
    System info: host: 'VIEWSU-5', ip: '172.16.10.32', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_20'
    Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.Executable.(Executable.java:72)
    at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59)
    at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95)
    at TestPack1.Test1Class.main(Test1Class.java:11)

  15. Looks like webdriver Is not able to find your firefox binary path. add bellow given line before WebDriver driver = new FirefoxDriver(); syntax to set binary path. It will work.

    System.setProperty("webdriver.firefox.bin","C:/Program Files/Mozilla Firefox/firefox.exe");

  16. Hi , I am new to Selenium and when I tried the abpuve code with SL 2.44 and FF33.1.1 , I am getting the below error

    Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    4c6-7e08-4474-a285-3208198ce6fd} visible
    1422264902527 DeferredSave.extensions.json DEBUG Save changes
    1422264902528 DeferredSave.extensions.json DEBUG Save changes
    1422264902528 addons.xpi DEBUG New add-on {D19CA586-DD6C-4a0a-96F8-14644F340D60} installed in winreg-app-global
    1422264902535 addons.xpi-utils DEBUG Make addon winreg-app-global:{D19CA586-DD6C-4a0a-96F8-14644F340D60} visible
    1422264902535 DeferredSave.extensions.json DEBUG Save changes
    1422264902535 DeferredSave.extensions.json DEBUG Save changes

  17. Hi I am new to Selenium, Tried the above vode with Selenium 2.44 and Ff 31.4.0.But getting below error.

    Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    s (x86)Mozilla Firefox_MMCde-DE@dictionaries.addons.mozilla.org
    1424274455735 addons.xpi DEBUG Loading bootstrap scope from C:Program Files (x86)Mozilla Firefox_MMCde-DE@dictionaries.addons.mozilla.org
    1424274455737 addons.xpi DEBUG Calling bootstrap method startup on de-DE@dictionaries.addons.mozilla.org version 2.0.4
    1424274455739 addons.xpi DEBUG Registering manifest for C:Program Files (x86)Mozilla Firefox_MMCen-gb@flyingtophat.co.uk
    1424274455739 addons.xpi DEBUG Loading bootstrap scope from C:Program Files (x86)Mozilla Firefox_MMCen-gb@flyingtophat.co.uk

  18. yes exactly, even I get the same error and when i add "System.setProperty("webdriver.chrome.driver", "C:\chromedriver_win32\chromedriver.exe");" then the code is executed successfully.

    Please let me know why webdriver is not able to find the chrome binary path?

  19. sorry i missed to mention the line that I added:

    System.setProperty("webdriver.chrome.driver", "C:\chromedriver_win32\chromedriver.exe");

  20. when i execute the above code the follwoing error is displayed but in the same code when i add "" line then the error is removed and am able to execute the code successfully. Can you let me know why so?

    error message before adding that line:
    Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
    at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:117)
    at SeleniumDemoWD.JTWebdriverTest.main(JTWebdriverTest.java:10)

  21. Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
    at mytestpack.mytestclass.main(mytestclass.java:8)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    … 1 more
    igot this Error.Plz.Help me

  22. i am getting this error
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at Testing_pack.mytestclass.main(mytestclass.java:8)

    my code is
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at Testing_pack.mytestclass.main(mytestclass.java:8)

    please help me as soon as possible

  23. Hi,

    I'm new to Selenium. I have tried the above program.

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
    at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:96)
    at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:70)
    at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:58)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:97)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:117)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:218)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120)
    at TestjUnit.mytestclass.main(mytestclass.java:9)
    Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    … 11 more

    Please let me know if I have anything.

    Thanks

  24. I have been googling for two days for tutorial on Selenium. All ended up having some errors. But your tutorial is clearly explained step by step and worked in the first try itself. Thank you so much for this awesome tutorial.

  25. Hi , I am new to Selenium and when I tried the above code with SL 2.53.0 and FF45.0.2 , I am getting the below error

    java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 51.0

    Thanks

    Michel

  26. Hello,

    Hi , I am new to Selenium and when I have SL 2.53.0 and FF 45.0.2 , I am getting the error :

    java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 51.0

    Thanks

    dormont

  27. Hi,

    When i am using the above code. Following error is coming.

    org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    ue,"userDisabled":false,"appDisabled":false,"descriptor":"C:\Program Files\Mozilla Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1461765373659,"updateDate":1461765373659,"applyBackgroundUpdates":1,"skinnable":true,"size":22006,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"46.0","maxVersion":"46.0"}],"targetPlatforms":[],"seen":true}
    1461833567120 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
    1461833567121 DeferredSave.extensions.json DEBUG Save changes
    1461833567121 addons.xpi DEBUG Updating database with changes to installed add-ons
    1461833567121 addons.xpi-utils DEBUG Updating add-on states
    1461833567122 addons.xpi-utils DEBUG Writing add-ons list
    1461833567124 addons.xpi DEBUG Registering manifest for C:Program FilesMozilla Firefoxbrowserfeaturese10srollout@mozilla.org.xpi
    1461833567124 addons.xpi DEBUG Calling bootstrap method startup on e10srollout@mozilla.org version 1.0
    1461833567124 addons.xpi DEBUG Registering manifest for C:Program FilesMozilla Firefoxbrowserfeaturesfirefox@getpocket.com.xpi
    1461833567124 addons.xpi DEBUG Calling bootstrap method startup on firefox@getpocket.com version 1.0
    1461833567125 addons.xpi DEBUG Registering manifest for C:Program FilesMozilla Firefoxbrowserfeaturesloop@mozilla.org.xpi
    1461833567126 addons.xpi DEBUG Calling bootstrap method startup on loop@mozilla.org version 1.2.6
    1461833567140 addons.xpi DEBUG Registering manifest for C:Program FilesMozilla Firefoxbrowserextensions{82AF8DCA-6DE9-405D-BD5E-43525BDAD38A}.xpi
    1461833567140 addons.xpi DEBUG Calling bootstrap method startup on {82AF8DCA-6DE9-405D-BD5E-43525BDAD38A} version 8.0.0.9103
    1461833567254 addons.manager DEBUG Registering shutdown blocker for XPIProvider
    1461833567255 addons.manager DEBUG Provider finished startup: XPIProvider
    1461833567255 addons.manager DEBUG Starting provider: LightweightThemeManager

  28. Thanks for your amazing tutorials. But After running the code above, I am getting following error.

    Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
    Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
    System info: host: 'DESKTOP-EOKA2KD', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_79'
    Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:218)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120)
    at test.test.main(test.java:12)
    Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
    at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
    at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
    at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
    at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)
    at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160)
    at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:380)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
    … 7 more

    Can you please help me to solve the problem?

  29. Hi,

    Your gave amazing explanation. I did follow your steps. But, when i run it below error is coming.

    Please help

    Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
    at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
    at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:220)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:215)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:124)
    at TestPackage.TestClass.main(TestClass.java:9)

  30. Hi….I started learning Selenium webdriver and, this blog is very useful for basics who learning newly.

    I encounter the below error whil execute the above script. please check let me know if any configuration is missed

    Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
    at mytestpack.mytestclass.main(mytestclass.java:9)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    … 1 more

  31. for people having errors in selenium firefox program you need driver manager that is hosted in github

    https://github.com/bonigarcia/webdrivermanager

    steps:

    1)you need the following dependency

    io.github.bonigarcia
    webdrivermanager
    1.4.9

    2) Your program looks like this
    MarionetteDriverManager.getInstance().setup();
    WebDriver driver = new FirefoxDriver();
    driver.get("http://only-testing-blog.blogspot.in");
    String i = driver.getCurrentUrl();
    System.out.println(i);
    driver.quit();

    3) just run the program

    following are other dependecies

    org.seleniumhq.selenium
    selenium-firefox-driver
    3.0.0-beta4

    org.seleniumhq.selenium
    selenium-api
    3.0.0-beta4

  32. QUESTION:_ " I am getting the below information in console. Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function"
    ANSWER: Copy and paste this line of code System.setProperty("webdriver.gecko.driver", "C:\\EclipseMaka2017\GECKO\geckodriver.exe");
    right after
    "{"
    but before
    "WebDriver driver = new FirefoxDriver();" :

  33. hi,

    i'm getting this issue as i run the test cases

    Exception in thread "main" org.apache.bcel.verifier.exc.AssertionViolatedException:
    FOUND:
    INTERNAL ERROR: Oops!
    Exiting!!

    at org.apache.bcel.verifier.exc.AssertionViolatedException.main(AssertionViolatedException.java:102)
    can anybody help on this.

  34. I tried this but I'am facing a problem with the below exceptions.
    Could anyone help me on this?

    package mytestpack;

    public class mytestclass {

    public static void main(String[] args) {

    WebDriver driver = new FirefoxDriver();
    driver.get("http://only-testing-blog.blogspot.in");
    String i = driver.getCurrentUrl();
    System.out.println(i);
    driver.close();
    }
    }

    Description Resource Path Location Type
    FirefoxDriver cannot be resolved to a type mytestclass.java /testproject/src/mytestpack line 11 Java Problem
    FirefoxDriver cannot be resolved to a type mytestclass.java /testprojects/src/mytestpacks line 7 Java Problem
    The import org.openqa cannot be resolved mytestclass.java /testproject/src/mytestpack line 3 Java Problem
    The import org.openqa cannot be resolved mytestclass.java /testproject/src/mytestpack line 5 Java Problem
    The method close() is undefined for the type WebDriver mytestclass.java /testproject/src/mytestpack line 15 Java Problem
    The method get(String) is undefined for the type WebDriver mytestclass.java /testproject/src/mytestpack line 12 Java Problem
    The method getCurrentUrl() is undefined for the type WebDriver mytestclass.java /testproject/src/mytestpack line 13 Java Problem
    WebDriver cannot be resolved to a type mytestclass.java /testprojects/src/mytestpacks line 7 Java Problem

  35. This is lovely. Thanks for sharing your knowledge.

    For MAC – after following same steps you will might get error.

    At this point, make sure you follow below steps

    brew install geckodriver
    export PATH=/my/firefox/path/bin:$PATH
    export PATH=/Users/geckodriver:$PATH

  36. This is lovely. Thanks for sharing your knowledge.

    For MAC – after following same steps you will might get error.

    At this point, make sure you follow below steps

    brew install geckodriver
    export PATH=/my/firefox/path/bin:$PATH
    export PATH=/Users/geckodriver:$PATH

  37. Just for new comer!!
    The below:
    System.setProperty("webdriver.gecko.driver","D:\Selenium Files\geckodriver.exe");
    //initialize firefox driver object to open firefox browser.
    WebDriver driver = new FirefoxDriver();

    should be:
    WebDriver driver;
    System.setProperty("webdriver.gecko.driver","D:\Selenium Files\geckodriver.exe");
    //initialize firefox driver object to open firefox browser.
    driver= new FirefoxDriver();

    Thank you Aravind G, God bless you.

    Mak

  38. Can't get this to work. i am getting 4 compilation errors: 1) Firefox Driver cannot be resolved to a type. 2) The import org.openqa cannot be resolved. 3) The import org.openqa cannot be resolved. 4) WebDriver cannot be resolved to a type. Please advise!!!

  39. Does not work for me. I am getting compile errors. 1) Firefox driver cannot be resolved to a type. 2) The import org.openqa cannot be resolved. 3) The import org.openqa cannot be resolved. 4) WebDriver cannot be resolved to a type.

Leave a Reply

Your email address will not be published. Required fields are marked *