selenium - 当我们尝试使用配置文件启动 Firefox 浏览器时,它没有启动
问题描述
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
解决方案
您的 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>
推荐阅读
- javascript - 将 HTML 链接到下拉列表的组合
- c# - 如何使 C# ReadLine() 方法保持相同的非英文字符?
- reactjs - Redux:将动作创建者导入另一个导致 typeError 'x is not a function'
- python - 使用 numpy 读取结构化二进制文件:fromfile vs. read & frombuffer
- android - 保存状态后如何安全弹出 FragmentManager 的回栈
- powershell - 在 TCL 代码中 - 如何读取 Windows 文本文件?
- haskell - Haskell:将字符串解析为自定义类型
- javascript - 如何从 JS 移植到 REACT
- ios - BLE 总是从 CBPeripheral 设备获取“状态 = 连接”
- sql-server - T-SQL MERGE:每个 GROUP BY 表达式必须至少包含一个不是外部引用的列