首页 文章

使用selenium webdriver运行测试

提问于
浏览
0

我是selenium web driver的新手 . 我有一个用java编写的测试,它将使用Selenium web驱动程序进行测试 . 我将测试类作为java应用程序运行 . 我编写了以下代码片段以获取ChromeDriver的实例 . 我收到以下代码片段的以下消息 .

@Override
    public WebDriver get() {
        log.info("Creating Chrome driver");
        try {
            return new ChromeDriver(buildCapabilities());
        } catch (IOException e) {
            throw new ExceptionInInitializerError(e);
        }
    }

还有ChromeDriver集的路径

private static final String CHROME_DRIVER =“chromedriver.exe”; URL chromeDriverUrl = getClass() . getResource(“/”CHROME_DRIVER); String pathToChromeDriver = chromeDriverUrl.getPath(); System.setProperty(“webdriver.chrome.driver”,pathToChromeDriver);

图片:
enter image description here

不明白为什么在返回新的ChromeDriver(buildCapabilities())代码行上显示以下消息 .

3 回答

  • 0

    要使用chrome驱动程序,你需要从here下载chrome驱动程序

    然后使用chrome驱动程序

    System.setProperty("webdriver.chrome.driver", "C:/Users/Hussain/Desktop/selenium-2.30.0/chromedriver.exe");
            WebDriver driver = new ChromeDriver();
    
  • 1

    嗯,首先,ChromeDriver(和FireFox驱动程序)都是RemoteWebDrivers,而不是WebDrivers . 这些类型不兼容 . 至于为什么你得到一个firefox驱动程序而不是一个chrome驱动程序,我猜你的buildCapabilities()函数或远程网格都返回一个firefox驱动程序 .

  • 0

    很简单的改变 . 将我的项目重新导入IntelliJ环境可以解决问题 .
    Reimport symbol in Intellij

相关问题