当我们尝试使用配置文件启动它时,Firefox浏览器没有启动[重复]

问题描述 投票:-1回答:2
We'd like to  launch the Firefox browser with profile initialization . but it is not opening and failing with below error message.

org.openqa.selenium.firefox.Preferences.readDefaultPreferences(Preferences.java:95)中的“java.lang.NoClassDefFoundError:org / openqa / selenium / remote / JsonToBeanConverter”

 **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
selenium firefox add profile
2个回答
0
投票

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

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

以下是工作代码。

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

0
投票

你的pom.xml显示你使用的是Selenium 3.14.0版,它不支持geckodriver 0.24;尝试更新到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>
© www.soinside.com 2019 - 2024. All rights reserved.