Example #1
0
 /**
  * Assert that an alert box is displayed, and contains the given text.
  *
  * @param  string  $text
  * @param  boolean $accept
  * @return
  */
 public function seeInAlert($text, $accept = true)
 {
     try {
         $alert = $this->session->alert_text();
     } catch (\WebDriver\Exception\NoAlertOpenError $e) {
         throw new PHPUnitException("Could not see '{$text}' because no alert box was shown.");
     } catch (\WebDriver\Exception\UnknownError $e) {
         // This would only apply to the PhantomJS driver.
         // It seems to have issues with alerts, so I'm
         // not sure what we can do about that...
         return $this;
     }
     $this->assertContains($text, $alert);
     if ($accept) {
         $this->acceptAlert();
     }
     return $this;
 }
Example #2
0
 /**
  * Check if popup don't contains the $text
  *
  * Example:
  * ``` php
  * <?php
  * $I->click();
  * $I->dontSeeInPopup('Error message');
  *
  * ```
  *
  * @param string $text
  */
 public function dontSeeInPopup($text)
 {
     $this->assertNotContains($text, $this->webDriverSession->alert_text());
 }