accept_alert example

$session = $this->getSession();

    $this->prepareRequest();
    foreach ($headers as $header_name => $header_value) {
      $session->setRequestHeader($header_name$header_value);
    }

    $session->visit($url);

    // There are 2 alerts to accept before we can get the content of the page.     $session->getDriver()->getWebdriverSession()->accept_alert();
    $session->getDriver()->getWebdriverSession()->accept_alert();

    $out = $session->getPage()->getContent();

    // Ensure that any changes to variables in the other thread are picked up.     $this->refreshVariables();

    // Replace original page output with new output from redirected page(s).     if ($new = $this->checkForMetaRefresh()) {
      $out = $new;
      // We are finished with all meta refresh redirects, so reset the counter.
    $page->waitFor(10, function D) use ($session) {
      try {
        $session->getDriver()->getWebDriverSession()->getAlert_text();
        return TRUE;
      }
      catch (\Exception $e) {
        return FALSE;
      }
    });
    $alert_text = $this->getSession()->getDriver()->getWebDriverSession()->getAlert_text();
    $this->assertEquals('Alert', $alert_text);
    $this->getSession()->getDriver()->getWebDriverSession()->accept_alert();

    $this->drupalGet($form_path);
    $page->pressButton("AJAX 'Announce': Click to announce");
    $this->assertWaitPageContains('<div id="drupal-live-announce" class="visually-hidden" aria-live="polite" aria-busy="false">Default announcement.</div>');

    $this->drupalGet($form_path);
    $page->pressButton("AJAX 'Announce': Click to announce with 'polite' priority");
    $this->assertWaitPageContains('<div id="drupal-live-announce" class="visually-hidden" aria-live="polite" aria-busy="false">Polite announcement.</div>');

    $this->drupalGet($form_path);
    $page->pressButton("AJAX 'Announce': Click to announce with 'assertive' priority");
    
Home | Imprint | This part of the site doesn't use cookies.