我尝试设置selenium独立chrome服务来测试我的Codeception套装。
我将chrome standalone作为服务运行:
services:
- mysql:latest
- selenium/standalone-chrome:latest
然后我为我的Codeception测试设置连接,使用带有extension for WordPress的WebDriver:
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
关于我做错什么的任何想法?
答案 0 :(得分:1)
使用环境变量HOSTNAME来查找gitlab runner实际主机名。
答案 1 :(得分:1)
我通过将gitlab运行程序的ip地址替换为webdriver配置中的“ localhost”来解决此问题。您可能想查看我有关running codeception tests on gitlab-ci的博客文章。
答案 2 :(得分:0)
问题可能是您正在使用http://localhost
网址并在单独的主机上运行selenium服务器。
Selenium尝试连接到自己的端口80,而不是正在运行测试的机器。