-1
We'd like to  launch the Firefox browser with profile initialization . but it is not opening and failing with below error message.

"java.lang.NoClassDefFoundError:org/openqa/selenium/remote/JsonToBeanConverter" at org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:95)

 **My current software version details** 
Selenium 3.14
Firefox browser 66
Gecko driver version V 0.24


System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
ProfilesIni prof = new ProfilesIni();
FirefoxProfile profile = prof.getProfile("Auto");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
return new FirefoxDriver(capabilities);


I tried to launch the Firefox browser with above configuration 
 As per the above code we have created a profile manually and trying to launch the browser with created profile . We have added add block plus plugin in the profile. because Random popup is appearing in our application . so we want to block it by adding the random popup filename is the add block plus filter.

**Actual Result :**Browser is not launching 
**Expected Result :**Browser should launch
Sai
  • 389
  • 6
  • 18
  • That type of warning tends to show up if your dependencies are missing something. What are you using to build the project? Of maven could you please add your Pom.xml file; if Gradle then please add your Gradle.build file, etc... – C. Peck Mar 29 '19 at 13:10
  • Hi Peck , it is launching successfully with below stmt . for example if i want to launch without profile. System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");new FirefoxDriver(); – Sai Mar 29 '19 at 13:16
  • Yes, but the error indicates that it cannot god “.org/openqa/selenium/**remote**/JSONToBeanConverter.java” could not be found. Do you have a version of selenium remote specified in your build file? – C. Peck Mar 29 '19 at 13:55
  • do you mean Selenium Standalone Server? if yes i did not mention it – Sai Mar 29 '19 at 14:10
  • No I mean selenium **remote**. That will have to be in your dependencies and imported. – C. Peck Mar 29 '19 at 14:14
  • it is in my repositry org.seleniumhq.selenium selenium-remote-driver 3.14.0 – Sai Mar 29 '19 at 14:21
  • Does that version match your selenium version? It would be great if you could just paste into your question your full Pom.xml file. I’m quite sure that is where the problem will be resolved. – C. Peck Mar 29 '19 at 14:31
  • HI Peck . the file is too long I am not able to paste here. may i know there is anyway to attach it – Sai Mar 29 '19 at 14:38
  • Can you paste just the dependencies? – C. Peck Mar 29 '19 at 14:38
  • org.seleniumhq.selenium selenium-java 3.14.0 org.apache.httpcomponents httpclient 4.5 org.seleniumhq.selenium selenium-java 3.14.0 org.seleniumhq.selenium selenium-remote-driver 3.14.0 – Sai Mar 29 '19 at 14:51
  • org.seleniumhq.selenium selenium-api 3.14.0 – Sai Mar 29 '19 at 14:51
  • org.seleniumhq.selenium selenium-java 3.14.0 org.seleniumhq.selenium selenium-remote-driver 3.14.0 org.seleniumhq.selenium selenium-api 3.14.0 – Sai Mar 29 '19 at 14:55
  • When I add the below code it is working fine FirefoxDriverManager.getInstance().setup(); FirefoxProfile profile = new FirefoxProfile( new File("C:\\Users\\XXXX\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\a409o534.XXXX_Auto")); FirefoxOptions options = new FirefoxOptions().setProfile(profile)WebDriver driver=new FirefoxDriver(options); – Sai Mar 29 '19 at 16:03
  • I did not change the dependency – Sai Mar 29 '19 at 16:03
  • Oh, well all’s well that ends well? As long as it’s working. – C. Peck Mar 29 '19 at 16:07
  • Thank you for support and help – Sai Mar 29 '19 at 16:43

2 Answers2

0

Make sure you have the Auto profile is created. See https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles for how to manage the profiles.

Close all firefox instances and open the firefox manager. You should see the profile in the list. enter image description here

Below is the working code.

ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("Auto");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, myprofile);
WebDriver driver =  new FirefoxDriver(capabilities);
driver.get("https://google.com");
driver.quit();
supputuri
  • 13,644
  • 2
  • 21
  • 39
  • I have created the profile as you suggested i follwed the same code but still i am getting the issue . is there anything i am missing – Sai Mar 29 '19 at 13:51
  • Can you post the console error message here. – supputuri Mar 29 '19 at 13:55
  • java.lang.NoClassDefFoundError: org/openqa/selenium/remote/JsonToBeanConverter at org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:95) at org.openqa.selenium.firefox.Preferences.(Preferences.java:65) at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:81) – Sai Mar 29 '19 at 14:40
  • Check your dependency in pom.xml. Here is mine ` org.seleniumhq.selenium selenium-java 3.141.59 ' – supputuri Mar 29 '19 at 15:21
  • HI When I add the below code it is working fine FirefoxDriverManager.getInstance().setup(); FirefoxProfile profile = new FirefoxProfile( new File("C:\\Users\\XXXX\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\a409o534.XXXX_Auto")); FirefoxOptions options = new FirefoxOptions().setProfile(profile)WebDriver driver=new FirefoxDriver(options); – Sai Mar 29 '19 at 16:43
0

Your pom.xml shows you are using Selenium version 3.14.0 which does not support geckodriver 0.24; try updating to selenium version 3.141.59 and you should only need the following dependencies for selenium:

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <version>3.141.59</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
            <scope>test</scope>
        </dependency>
C. Peck
  • 3,641
  • 3
  • 19
  • 36