Chromedriver无法与代码接收一起使用

时间:2019-04-25 09:04:07

标签: php automation selenium-chromedriver codeception

因此,我正在使用代码接收进行自动测试。使用phpbrowser效果很好,但是我要测试的页面使用ajax,所以我按照代码接收网站上的说明更改为webdriver。

我选择使用chromedriver,因为我将仅使用chrome进行此测试,但这会给我这个错误

Acceptance Tests (1) ---------------------------------------------------------------------------------------------------
FirstCest: Login successfully
Signature: FirstCest:loginSuccessfully
Test: tests\acceptance\FirstCest.php:loginSuccessfully
Scenario --
 ERROR

------------------------------------------------------------------------------------------------------------------------


Time: 722 ms, Memory: 8.00 MB

There was 1 error:

---------
1) FirstCest: Login successfully
 Test  tests\acceptance\FirstCest.php:loginSuccessfully

  [Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed.
Error code: 4
The response: 'unknown command: wd/hub/session'


#1  D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:298
#2  D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:126
#3  D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:212
#4  D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:44

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

我尝试将chromedriver.exe更改为chrome的安装路径,但仍然相同。我真的不知道如何为chromedriver配置url,因为它只是一个.exe。

这是我在代码接收方面的接受套件,以防万一:

actor: AcceptanceTester
modules:
      enabled:
        - WebDriver:
             url: 'http://localhost/ASTechOLE/login.php'
             window_size: false # disabled in ChromeDriver
             port: 9515
             browser: chrome
             capabilities:
                 "goog:chromeOptions": # additional chrome options
        - \Helper\Acceptance

预先感谢

更新: 我用./chromedriver --url-base=/wd/hub运行了chromedriver 现在它给了我

There was 1 error:

---------
1) FirstCest: Login successfully
 Test  tests\acceptance\FirstCest.php:loginSuccessfully

  [Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed.
Error code: 4
The response: 'unhandled request'


#1  D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:298
#2  D:\Programas\xampp\htdocs\autTest\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:126
#3  D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:212
#4  D:\Programas\xampp\htdocs\autTest\vendor\symfony\event-dispatcher\EventDispatcher.php:44

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

1 个答案:

答案 0 :(得分:0)

根据您的堆栈跟踪信息,似乎您正在Windows中工作。 尝试运行chromedriver,而不用前导斜杠wd/hub代替/wd/hub
您的命令将变为:./chromedriver --url-base=wd/hub
我知道,Windows有时可能很“有趣”:)