无法使用selenium 3.8.1和gecko驱动程序0.19.0找到匹配的功能集

问题描述 投票:5回答:4
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Webdriver {

    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub


        System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        //System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver.exe");
        //WebDriver driver = new ChromeDriver();

        driver.get("https://maps.mapmyindia.com");

        Thread.sleep(2000);
        driver.findElement(By.id("auto")).sendKeys("TCS");

        Thread.sleep(2000);
        driver.findElement(By.id("auto_geo")).click();

当我在eclipse luna上运行此代码时出现错误:线程“main”中的异常org.openqa.selenium.SessionNotCreatedException:无法找到匹配的一组功能

selenium firefox exception webdriver
4个回答
9
投票
new FirefoxDriver(DesiredCapabilities caps); 

已弃用,请使用

FirefoxOptions options = new FirefoxOptions();
options.setCapability("marionette", false);
WebDriver webDriver = new FirefoxDriver(options);

你很高兴


1
投票

你应该为firefox添加功能。请修改您的代码如下

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

 DesiredCapabilities capabilities = new DesiredCapabilities();

 capabilities = DesiredCapabilities.firefox();
 capabilities.setBrowserName("firefox");
 capabilities.setVersion("your firefox version");
 capabilities.setPlatform(Platform.WINDOWS);
 capabilities.setCapability("marionette", false);

 WebDriver driver = new FirefoxDriver(capabilities);

 driver.get("https://maps.mapmyindia.com");

如果你的窗户是windows_nt然后把windows_nt而不是windows


0
投票

SessionNotCreatedException

SessionNotCreatedException扩展WebDriverException并且是RuntimeException,表示无法创建会话。

可能的原因 :

无法创建新会话的可能原因如下:

  • JDKSeleniumWebDriverWeb Browser版本之间的兼容性问题。
  • GeckoDriverMarionette通过之前会话尚未发布的新会话访问相同的端口号。
  • 缺乏访问CPU
  • 缺乏Physical Memory
  • 缺乏Swap Memory
  • 缺乏Disc Cache
  • 缺乏Network Bandwidth
  • 系统内存在OS chores

代码块:

我没有在您的代码块中看到任何编码问题。

方案:

简单的解决方案如下:

  • 始终使用最新发布的JDK(Java SE 9.0.1),Selenium-Java客户端(v3.8.1),WebDriver变体(GeckoDriver v0.19.1)和Web浏览器(Firefox Quantum Browser)。
  • 如果Web浏览器的基本版本太旧,请考虑通过Revo Uninstaller卸载浏览器并安装最近发布的Firefox浏览器的GA版本。
  • 始终在tearDown()方法中使用quit(),以便正确销毁webdriver和webclient。
  • 在执行Test Suite之前和之后,从IDE清理Project Workspace。
  • 在执行测试之前和之后清除浏览器缓存。
  • 定期使用CCleaner工具擦除OS杂务。
  • 执行你的测试。

0
投票

另一个可能的原因是过时的Firefox版本。

我升级了版本,它工作正常!

我只能打开浏览器设置options.setCapability("marionette", true);,然后在打开的窗口中我通过“关于Firefox”对话框升级。然后你必须删除关于marionette的行。

可能我所拥有的只是与marionette合作,而我们正试图将它与geckodriver一起使用,qazxswpoi有不同的协议。任何比我更了解的人都可以确认或否认!

© www.soinside.com 2019 - 2024. All rights reserved.