【问题标题】:Firefox browser is not launching when we try to launch it with profile [duplicate]当我们尝试使用配置文件启动 Firefox 浏览器时,它没有启动 [重复]
【发布时间】:2019-03-29 13:02:23
【问题描述】:
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”在 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

【问题讨论】:

  • 如果您的依赖项缺少某些内容,则往往会出现这种类型的警告。你用什么来构建项目? maven,请您添加您的 Pom.xml 文件;如果 Gradle 那么请添加您的 Gradle.build 文件等...
  • 嗨 Peck ,它正在成功启动,并带有以下 stmt 。例如,如果我想在没有配置文件的情况下启动。 System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");new FirefoxDriver();
  • 是的,但是错误表明它不能上帝找不到“.org/openqa/selenium/**remote**/JSONToBeanConverter.java”。您的构建文件中是否指定了 selenium 远程版本?
  • 您是指 Selenium 独立服务器吗?如果是,我没有提到它
  • 不,我是说硒 remote。这必须在您的依赖项中并导入。

标签: selenium firefox add profile


【解决方案1】:

确保您已创建 Auto 配置文件。请参阅https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles 了解如何管理配置文件。

关闭所有 firefox 实例并打开 firefox 管理器。您应该会在列表中看到配置文件。

下面是工作代码。

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();

【讨论】:

  • 我已经按照您的建议创建了配置文件,我遵循了相同的代码,但我仍然遇到了问题。有什么我想念的吗
  • 你能在这里发布控制台错误信息吗?
  • 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)
  • 检查你在 pom.xml 中的依赖。这是我的`org.seleniumhq.seleniumselenium-java3.141.59'
  • HI 当我添加下面的代码时,它工作正常 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);
【解决方案2】:

您的 pom.xml 显示您正在使用不支持 geckodriver 0.24 的 Selenium 版本 3.14.0;尝试更新到 selenium 版本3.141.59,您应该只需要以下 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>

【讨论】:

    猜你喜欢
    • 2023-04-06
    • 2019-09-21
    • 2014-03-11
    • 1970-01-01
    • 2020-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多