我正在尝试在黄昏进行测试,但是我无法使其正常工作。
Docker-compose.yml
version: '3.7'
services:
### PHP Container #########################################
cipe:
container_name: cipe
hostname: cipe
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
working_dir: /var/www/html/app
volumes:
- .:/var/www/html/app
depends_on:
- cipedb
### NGINX Container #########################################
cipenginx:
container_name: cipe_nginx
hostname: cipenginx
image: nginx:1.17
restart: unless-stopped
depends_on:
- cipe
ports:
- 5000:80
volumes:
- .:/var/www/html/app
- ./docker/virtualhost.conf:/etc/nginx/conf.d/default.conf
### POSTGRESS Container #########################################
cipedb:
container_name: cipe_db
image: postgres:11
restart: always
environment:
POSTGRES_DB: cipe
POSTGRES_USER: cipe-user
POSTGRES_PASSWORD: secret
PGPASSWORD: secret
ports:
- '54321:5432'
volumes:
- postgres-data:/var/lib/postgresql/data
selenium:
image: selenium/standalone-chrome:3.11.0-antimony
depends_on:
- cipe
- cipenginx
links:
- cipenginx:cipe.test
volumes:
- /dev/shm:/dev/shm
### Volumes Setup ##########################################
volumes:
cipe:
postgres-data:
driver: "local"
nginx-data:
driver: "local"
DuskTestCase:
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
//static::startChromeDriver();
}
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--no-sandbox',
'--ignore-ssl-errors',
'--whitelisted-ips=""'
]);
if (env('USE_SELENIUM', 'false') == 'true') {
return RemoteWebDriver::create(
'http://selenium:4444/wd/hub', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
));
} else {
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
));
}
}
}
.env.dusk.local
APP_NAME=CIPE
APP_ENV=local
APP_KEY=base64:MYhWn7Cgxj5mIDfNnlxbVn7ZiyoCXG0Sr29fecKaTZ4=
APP_DEBUG=true
APP_URL=http://cipe.test/
当我执行以下测试时:
/** @test */
public function get_drivers()
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->assertSee('CIPE');
});
}
我遇到下一个错误:
1) Tests\Browser\DriverTest::get_drivers
Did not see expected text [CIPE] within element [body].
Failed asserting that false is true.
/页面为:
但是屏幕截图错误是Google: