.env内にて、とサーバーアドレスが設定されており、
php
1APP_URL=http://localhost:8000 2APP_DOMAIN=localhost
web サーバーとして、docker コンテナ apache2 を立ち上げています。
この状態で、duskをテストするために、selenium/standalone-chrome を別のコンテナで立ち上げました。
bash
1docker run -p 4444:4444 --name selenium --link apache2:apache2 -d selenium/standalone-chrome
コンテナ間の接続確認のため、
docker exec -it selenium bash後、
cat /etc/hosts/ の中身が
172.17.0.6 apache2 a1c15575e4c8
が入っており、
seleniumコンテナからapache2にpingは通ることは確認しました。
ただここから
docker
1docker exec apache2 php artisan dusk
でduskテストを行なったところ、
chromeは立ち上がっているものの、localhostに正常にアクセスできていないことがわかりました。(デバッグしてみると中身が何もない状態でした。)
設定が悪いのだろうと思いますが、どこに原因があるか分からないので、お助けいただければ幸いです。
DuskTestCase.php
php
1abstract class DuskTestCase extends BaseTestCase 2{ 3 use CreatesApplication; 4 5 /** 6 * Prepare for Dusk test execution. 7 * 8 * @beforeClass 9 * @return void 10 */ 11 public static function prepare() 12 { 13 static::startChromeDriver(); 14 } 15 16 /** 17 * Create the RemoteWebDriver instance. 18 * 19 * @return \Facebook\WebDriver\Remote\RemoteWebDriver 20 */ 21 protected function driver() 22 { 23 $options = (new ChromeOptions)->addArguments([ 24 '--disable-gpu', 25 '--headless' 26 ]); 27 return RemoteWebDriver::create( 28 'http://selenium:4444/wd/hub', DesiredCapabilities::chrome()->setCapability( 29 ChromeOptions::CAPABILITY, $options 30 ) 31 ); 32 } 33}
ExampleTest.php
php
1class ExampleTest extends DuskTestCase 2{ 3 public function testBasicExample() 4 { 5 $this->browse(function (Browser $browser) { 6 print_r($browser->visit('/')->resolver->elements);exit; 7 $browser->visit('/') 8 ->assertSee('次回から自動ログインする'); 9 }); 10 } 11} 12
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。