[英]Laravel 9 test dusk does not work on Docker with selenium/standalone-chrome
我根據laravel文檔安裝了dusk,但是在docker交互模式下無法運行測試dusk。 我搜索了 web 沒有找到正確的配置。 這是 docker-compose 文件的一部分:
services:
php-apache:
build:
context: .
container_name: app_php
ports:
- '8081:80'
volumes:
- ./core:/var/www/app
- ./apache/default.conf:/etc/apache2/sites-enabled/000-default.conf
links:
- selenium
depends_on:
- database
networks:
- mysite
selenium:
image: selenium/standalone-chrome:104.0
container_name: selenium
ports:
- "4444:4444"
networks:
- mysite
這是我得到的錯誤:
1) Tests\Browser\ExampleTest::testBasicExample TypeError: Facebook\WebDriver\Remote\DesiredCapabilities::__construct(): Argument #1 ($capabilities) must be of type array, null given, called in /var/www/app/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php on line 648
我已經花了兩天時間來解決這個問題。 如果有人能幫助我,我將不勝感激。
在您的 duskTestCase.php 文件中,在驅動程序 function 中,將這兩行添加到選項中:
'--whitelisted-ips=""',
'--disable-dev-shm-usage'
第一行允許容器通信,第二行解決 dev-shm 掛載參考問題: https://github.com/SeleniumHQ/docker-selenium/issues/1267
同樣在同一個驅動程序 function 上,url 必須指向您的 selenium 容器:
return RemoteWebDriver::create(
'http://selenium:4444/wd/hub',
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.