【发布时间】:2021-06-16 15:14:43
【问题描述】:
我正在尝试设置 Codeception 来为我的 Web 应用程序进行验收和功能测试。以下是我的文件:
docker-compose.yml
version: '3.7'
services:
# nginx - web server
nginx:
build:
context: ./docker-config/nginx
dockerfile: ./Dockerfile
env_file: &env
- ./cms/.env
init: true
ports:
- "8000:80"
volumes:
- cpresources:/var/www/project/cms/web/cpresources
- ./cms/web:/var/www/project/cms/web:cached
networks:
mmc-network:
aliases:
- mmc.nginx
# php - run php-fpm
php:
build: &php-build
context: ./docker-config/php-prod-craft
dockerfile: ./Dockerfile
depends_on:
- "mysql"
- "redis"
env_file:
*env
expose:
- "9000"
init: true
volumes: &php-volumes
- some volumes............
networks:
mmc-network:
aliases:
- mmc.php
# mysql - database
mysql:
build:
context: ./docker-config/mysql
dockerfile: ./Dockerfile
cap_add:
- SYS_NICE # CAP_SYS_NICE
env_file:
*env
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: project
MYSQL_USER: project
MYSQL_PASSWORD: project
init: true
ports:
- "3306:3306"
volumes:
- db-data:/var/lib/mysql
- ./db-seed/:/docker-entrypoint-initdb.d
networks:
- MMC-network
# redis - key/value database for caching & php sessions
redis:
build:
context: ./docker-config/redis
dockerfile: ./Dockerfile
expose:
- "6379"
init: true
networks:
- mmc-network
# webpack - frontend build system
webpack:
build:
context: ./docker-config/node-dev-webpack
dockerfile: ./Dockerfile
env_file:
*env
init: true
ports:
- "8080:8080"
volumes:
- some volumes..........
networks:
- mmc-network
# selenium - web driver for codeception testing
selenium:
container_name: mmc-selenium
ports:
- "4444:4444"
volumes:
- ./cms:/data
build:
context: ./docker-config/selenium
dockerfile: ./Dockerfile
networks:
mmc-network:
aliases:
- mmc.selenium
volumes:
db-data:
cpresources:
storage:
networks:
mmc-network:
acceptance.suite.dist.yml:
actor: AcceptanceTester
extensions:
enabled:
- Codeception\Extension\RunFailed
- Codeception\Extension\Recorder
modules:
error_level: "E_ALL"
enabled:
- WebDriver:
url: 'http://mmc.nginx'
host: mmc.selenium
port: '4444'
window_size: 1920x1200
browser: 'chrome'
wait: 60
capabilities:
os: Windows
os_version: 10
browserstack.local: true
- \Helper\Acceptance
NavigationCept.php
<?php
$I = new AcceptanceTester($scenario);
# define purpose of the test
$I->wantTo("check that navigation is functional.");
# check all menu items
$I->amOnPage('/');
$I->see('Search');
***现在,需要注意的是,Codeception 已经安装在我的 PHP 容器中并且工作正常。
当我尝试运行测试时,我收到以下错误,表明与我的主机(即我的 Nginx 服务器)的连接已被拒绝。
我尝试使用不同的url,例如https://google.com,它连接良好,一切顺利。我在这里做错了吗?我的url 参数不正确吗?如果可以的话,请帮助我。提前致谢。
【问题讨论】:
-
你能用 --debug 标志运行测试并在此处复制输出吗
-
你的 nginx 监听的是 8000 端口,而不是 80 端口。你如何通知客户端这件事? (对不起,对 WebDriver 参数一无所知)。
url: http://mmc.nginx:8000不会帮忙吗? -
嗨,@OlesyaBolobova 我想我已经尝试过了,但不确定。我会尝试并让你知道。 :)
-
我会通过进入 selenium 容器来调试它,看看你从那里得到了什么
docker-compose exec -it selenium bashcurl http://mmc.nginx/- 将输出添加到你的问题中。 -
@WilliamFrancisGomes 你能解决这个问题吗?
标签: php docker selenium nginx codeception