2

FacebookのPHP WebDriverとSeleniumを使用して一連のテストを実行しました。私はphpunitをChrome上で実行します。テストはWindowsマシン上で実行され、ロードされたページはUbuntu VMからのものです。php、selenium、およびchromedriverを使用したWebdriverCurlException

ほとんどの場合、すべてがうまくいきます。しかし、しばらくの間、テストは最初にいくつかの失敗した権利で驚くようにエラーになります。 Chromeのウィンドウが開き、目的のURLが入力され、何も表示されません。これは、約30秒のための 'ロード' を押した後に次のように出力されますPHPUnitの5.5.4、PHPの7.0.10、Seleniumサーバー2.53を使用して

Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/be8e5886-7d05-4eb5-a798-143fb7ed3b30/url with params: {"url":"http:\/\/app.name.test"} 

Operation timed out after 30000 milliseconds with 0 bytes received 

E:\dev\foldername\vendor\facebook\webdriver\lib\Exception\WebDriverException.php:92 
E:\dev\foldername\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:320 
E:\dev\foldername\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:547 
E:\dev\foldername\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:195 
E:\dev\foldername\tests\FunctionalTestBase.php:40 
E:\dev\foldername\tests\TypeChangeWithRoute2Test.php:18 

Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http GET to /session/d86523c4-6b25-4e61-bc2c-bc0cd3e615f4/title 

Operation timed out after 30000 milliseconds with 0 bytes received 

E:\dev\foldername\vendor\facebook\webdriver\lib\Exception\WebDriverException.php:92 
E:\dev\foldername\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:320 
E:\dev\foldername\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:547 
E:\dev\foldername\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:227 
E:\dev\foldername\vendor\facebook\webdriver\lib\WebDriverExpectedCondition.php:60 
E:\dev\foldername\vendor\facebook\webdriver\lib\WebDriverWait.php:60 
E:\dev\foldername\tests\FunctionalTestBase.php:44 
E:\dev\foldername\tests\ReorderQuestionsTest.php:18 

はまた、時々これを投稿します。 1、Chromedriver 2.23、Chrome 53.0.2785.89。

私が試したこと: ChromeDriverを2.9にアップデートしました(別の問題が導入されましたが、これは修正されません)。 $ webDriver-> get($ this-> url)呼び出しの後にタイムアウトを追加する。 はこれを追加する:

try{ 
    $this->webDriver->wait(5)->until(Condition::titleIs('Login')); 
}catch(TimeOutException $e){ 
    $this->webDriver->get($this->url); 
} 

を私はDBUS_SESSION_BUS_ADDRESS =は/ dev/nullに設定の言及を見つけた

-jar代わりにコマンドjavaの右クリック - >オープンwith->のJavaでSeleniumサーバーを起動するが、私はどこにそれを追加するかを見つけることができないようです。

マイセットアップ機能:

$capabilities = Capabilities::chrome(); 
     $this->webDriver = Driver::create('http://localhost:4444/wd/hub', $capabilities); 
     $this->webDriver->manage()->window()->maximize(); 
     $this->webDriver->get($this->url); 

     try{ 
      $this->webDriver->wait(2)->until(Condition::titleIs('Login')); 
     }catch(TimeOutException $e){ 
      $this->webDriver->get($this->url); 
     } 

マイティアダウン機能:

$this->webDriver->quit(); 

は、私が何をすべきかで迷ってしまいました。ランダムに失敗したテストは使用できません。 まあ、私はFirefoxで同じ問題を得たが、いませんでしたPhantomJS:

私も

try { 
    $this->webDriver->get($this->url); 
} catch (WebDriverCurlException $e) { 
    $this->tearDown(); 
    $this->setUp(); 
} 

UPDATEを試みました。私は、Selenium Server 2.53に何か問題があると推測しています...

+0

私は、ネットワークが重い負荷の下にあるように見えるときに、トラビスがこのように失敗することを発見しました。ビルドを再開するだけで、トラフィックが減速しリソースが解放されると最終的には成功します。 –

答えて

0

Driver :: createでクライアントを作成するときは、$ request_timeout_in_msを4番目のパラメータとして設定できます。 例えば:

Driver::create('http://localhost:4444/wd/hub', $capabilities, 60000, 60000); 

接続し、60秒に要求のタイムアウトを設定します。

関連する問題