selenium - Selenium-Firefox 驱动程序问题(Firefox 驱动程序无法解析为类型
问题描述
我正在尝试使用 maven 编写简单的 selenium 脚本,但是尽管通过 maven 下载了所有依赖的 selenium jar,但 firefox 驱动程序出现错误。
请参阅下面的屏幕截图:非常感谢任何帮助
解决方案
试试这个代码:
public class NewTest {
public WebDriver driver;
@BeforeClass
public void setupClass() {
System.setProperty("webdriver.gecko.driver", "C:\\Users\\***\\Downloads\\chromedriver_win32\\geckodriver.exe");
driver = new FirefoxDriver();
}
@Test
public void openMyBlog() {
driver.get("http://www.google.com");
System.out.println("This is first test");
}
@AfterClass
public void tearDownClass() {
// driver.quit();
}
}
确保您已导入所有必需的包。
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
推荐阅读
- android - 无法在没有 Firebase 的情况下对本地通知做出本机推送通知
- java - `ConnectException` 的 TCP 错误是什么?
- node.js - 如何更新数组中的特定对象?
- ios - 检查用户的位置是否在印度
- node.js - 每当捕获错误或控制台错误出现并且服务器在本地主机或生产端(heroku)停止时,如何在 UI 上显示错误警报?
- reactjs - AntDesign 表单或 React Hook 表单
- checkbox - 复选框不启用字段淘汰赛
- office-js - 是否可以使用 MS PowerPoint 插件选择/更新形状/图标/图像属性?
- ios - StoreKitTest:请求产品错误域=ASDErrorDomain 代码=950“未处理的异常”
- node.js - “GeometryDataType”类型中不存在坐标