我正在尝试设置 selenium 独立 chrome 服务来测试我的 Codeception 套装。
我将 chrome 独立运行为服务:
services:
- mysql:latest
- selenium/standalone-chrome:latest
然后我使用带有 extension for WordPress 的 WebDriver 为 Codeception 测试设置连接。 :
WPWebDriver:
url: 'http://localhost'
host: 'selenium__standalone-chrome'
browser: chrome
port: 4444
restart: true
wait: 2
adminUsername: admin
adminPassword: 1234
adminUrl: /wp-admin
所有其他测试都运行良好,但当涉及到我使用 Selenium 的套件时,它拒绝连接:
Time: 7.55 seconds, Memory: 16.00MB
There was 1 failure:
---------
1) SampleTestCept: Test if wp is working in selenium
Test tests/php/acceptance/SampleTestCept.php
Step See "Just another WordPress site"
Fail Failed asserting that on page /
--> This site can’t be reached
localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
Reload
DETAILS
--> contains "this site can't be reached".
Scenario Steps:
2. $I->see("This site can't be reached") at tests/php/acceptance/SampleTestCept.php:6
1. $I->amOnPage("/") at tests/php/acceptance/SampleTestCept.php:4
我做错了什么有什么想法吗?
请您参考如下方法:
使用环境变量 HOSTNAME,查找 gitlab runner 的实际主机名。