【问题标题】:error: The path to the driver executable must be set by the webdriver.gecko.driver system property错误:驱动程序可执行文件的路径必须由 webdriver.gecko.driver 系统属性设置
【发布时间】:2017-03-16 21:18:54
【问题描述】:

我正在使用 PHP 进行自动化功能单元测试。我想使用 PhpStorm 在暂存环境上运行测试,我正在关注此链接:https://www.sitepoint.com/using-selenium-with-phpunit/。我有完成此代码的任务: 我已经访问过这个链接,但对我不起作用。 The path to the driver executable must be set by the webdriver.gecko.driver system property

<?php

/**
 * Created by PhpStorm.
 * User: Developer4
 * Date: 11/2/2016
 * Time: 1:41 PM
 */
class uatTest extends PHPUnit_Extensions_Selenium2TestCase
{
    public function setUp()
    {
        $this->setHost('localhost');
        $this->setPort(4444);
        $this->setBrowserUrl('https://www.facebook.com/');

        $this->setBrowser('firefox');
    }
    public function tearDown()
    {
        $this->stop();
    }
    public function validInputsProvider()
    {
        $inputs[] = [
            [
                'email'              => 'user',
                'pass'              => 'pass'
            ]
        ];
        return $inputs;
    }
    public function testFormSubmissionWithUsername()
    {
        $this->byName('email')->value('user');
        $this->byId('loginbutton')->submit();
        $email = $this->byName('email');
        $this->assertEquals('user', $email->value());
    }
}

当我的 selenium 服务器正在运行时:

当我在 phpstorm 上运行我的测试时,我得到了这个错误

错误:

C:\wamp\bin\php\php5.6.25\php.exe C:/wamp/www/PHPUnit-and-Composer-Workflow/vendor/phpunit/phpunit/phpunit --no-configuration uatTest C:\wamp\www\PHPUnit-and-Composer-Workflow\test\uatTest.php --teamcity
Testing started at 2:53 PM ...
PHPUnit 5.6.2 by Sebastian Bergmann and contributors.


The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.php:165
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\Driver.php:72
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase\SessionStrategy\Isolated.php:67
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:296
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:337
 C:\wamp\www\PHPUnit-and-Composer-Workflow\vendor\phpunit\phpunit-selenium\PHPUnit\Extensions\Selenium2TestCase.php:314



Time: 823 ms, Memory: 3.50MB


ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Process finished with exit code 2

并且在 cmd 上也获得异常:

【问题讨论】:

    标签: php selenium phpunit phpstorm


    【解决方案1】:

    这是解决方案:

        java -Dwebdriver.gecko.driver="C:\Users\Developer4\Downloads\geckodriver-v0.11.1-win32\geckodriver.exe" -jar C:\wamp\bin\php
    
    \php5.6.25\selenium-server-standalone-3.0.1.jar
    

    【讨论】:

      猜你喜欢
      • 2017-09-11
      • 1970-01-01
      • 2017-12-21
      • 1970-01-01
      • 2020-03-14
      • 2017-02-04
      • 2016-12-05
      • 2013-08-18
      • 2017-09-07
      相关资源
      最近更新 更多