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

问题描述 投票:0回答:2

所以我正在使用代码接收进行自动化测试。使用 phpbrowser 运行良好,但我想测试的页面使用 ajax,所以我按照 codeception 网站上的说明更改为 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.

php automation selenium-chromedriver codeception
2个回答
2
投票

根据您的堆栈跟踪,您似乎正在 Windows 中工作。 尝试运行 chromedriver,不要以斜杠开头,使用

wd/hub
而不是
/wd/hub

然后您的命令将变为:
./chromedriver --url-base=wd/hub

我知道,Windows 有时也很“有趣”:)


0
投票

使用日志选项运行 chromedriver 以了解更多信息。

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