【问题标题】:Selenium Web driver 3.3.1Selenium Web 驱动程序 3.3.1
【发布时间】:2017-08-15 15:02:33
【问题描述】:

我将Eclipse IDE 用于selenium 3.3.1。我添加了进出 lib 文件夹的 selenium 3.3.1 jar 文件。

Eclipse version is Helios Service Release 1. 
firefox version is 52.0.1(32 Bit). 
JDK version is 1.8.0_05. 

但我还是得到了错误

import org.openqa.selenium.firefox cannot be resolved.  

我也试过下面的代码:

System.setProperty("webdriver.firefox.marionette","C:\\selenium-java-3.3.1\\geckodriver-v0.15.0-win64\\geckodriver.exe");

但是,它没有为我工作。

谁能帮我解决这个问题?

【问题讨论】:

  • @alexandrum 如果它是一个副本,对我来说它看起来并不明显
  • 也许你复制了错误的 JAR 或者没有将它们添加到构建路径中。
  • @MarioTrucco 这不是直接用于导入问题,而是更多用于属性设置。指定问题的答案有一个示例链接。
  • 3.3.1版本不适用。以下是版本 3.3.0 的更新 * 支持 geckodriver v0.15.0。 * 已弃用很少使用的 FirefoxDriver 构造函数。 * 添加了 javadocs 以显示创建新 FirefoxDriver 的最佳方法:``` DesiredCapabilities caps = new FirefoxOptions() // 仅用于示例目的 .setProfile(new FirefoxProfile()) .addTo(DesiredCapabilities.firefox()); WebDriver driver = new FirefoxDriver(caps);

标签: java eclipse selenium firefox


【解决方案1】:

将“webdriver.firefox.marionette”更改为“webdriver.gecko.driver”

【讨论】:

  • 这不会为 import not found 错误做任何事情,这是一个编译时错误。
  • 需要导入以下内容:org.openqa.selenium.firefox.FirefoxDriver;
  • @Kushal。我也试过了。但错误在于导入。
  • 以下是建议的导入包。但是没有列出 FirefoxDriver 包。 (1) Gecko Driver Service (2) Firefox Profile (3) Extension Connection (4) NotConnected Exception (5) UnableToCreateProfileException (6) firefoxamd64 (7) firefox.internal (8) firefoxx86
  • 你确定你添加了以下命令:import org.openqa.selenium.firefox.FirefoxDriver;
【解决方案2】:

试试这个方法。

1) 更新 firefox 浏览器 52 或以上版本
2) 更新selenium java jar 文件,您可以从site 下载更新后的jar 文件。
3) 更新gecko驱动,您可以从site下载更新的gecko驱动。

有关如何在 eclipse 中更新上述设置的更多详细信息,请参阅site

现在重新启动一次 Eclipse 并尝试运行您的自动化脚本。

【讨论】:

  • 你试过这个解决方案了吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-28
  • 2020-05-04
  • 2018-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多