首页 > 解决方案 > Selenium-Firefox 驱动程序问题(Firefox 驱动程序无法解析为类型

问题描述

我正在尝试使用 maven 编写简单的 selenium 脚本,但是尽管通过 maven 下载了所有依赖的 selenium jar,但 firefox 驱动程序出现错误。

请参阅下面的屏幕截图:非常感谢任何帮助

在此处输入图像描述

标签: seleniumselenium-webdriverselenium-firefoxdriver

解决方案


试试这个代码:

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;

推荐阅读