Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 类型不匹配:无法从FireFoxDriver转换为WebDriver_Selenium - Fatal编程技术网

Selenium 类型不匹配:无法从FireFoxDriver转换为WebDriver

Selenium 类型不匹配:无法从FireFoxDriver转换为WebDriver,selenium,Selenium,你看到IDE中的输入错误了吗?您已经导入了FirefoxDriver并尝试实例化FirefoxDriver您的代码中有两个问题,如下所示: System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe"); 导入: 正如您使用的import org.openqa.selenium.firefox.FirefoxDriver在您必须使用的类似行上: WebDriver driver = new Firef


你看到IDE中的输入错误了吗?您已经导入了
FirefoxDriver
并尝试实例化
FirefoxDriver

您的代码中有两个问题,如下所示:

System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
  • 导入

    正如您使用的
    import org.openqa.selenium.firefox.FirefoxDriver在您必须使用的类似行上:

    WebDriver driver = new FirefoxDriver();
    
  • System.setProperty()

    当您使用Selenium v3.x.x时,您必须从此下载最新的
    geckodriver
    二进制文件,将其保存在您的系统中,并通过
    系统.setProperty()提供
    geckodriver
    二进制文件的绝对路径
    行如下:

    System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");