title: How to confirm ok of popup in Behat?
body: <p>I want to confirm the popup when it appears.
  Here is the feature file:</p>
  
  <pre>And I wait 10 seconds
  Then I confirm the popup
  </pre>
  
  <p>And The FeatureContext file:</p>
  
  <pre><code>&lt;?php
  
      use Behat\Behat\Context\Context;
      use Behat\Behat\Context\SnippetAcceptingContext;
      use Behat\Gherkin\Node\PyStringNode;
      use Behat\Gherkin\Node\TableNode;
      use Behat\MinkExtension\Context\MinkContext;
      use Behat\Mink\Driver\Selenium2Driver;
  
      class FeatureContext extends MinkContext { 
      /**
       * @when /^(?:|I )confirm the popup$/
       */
          public function confirmPopup()   {
              $this-&gt;getSession()-&gt;getDriver()-&gt;getWebDriverSession()-&gt;accept_alert();
          }
      }
  </code></pre>
  
  <p>But it doesn't work. It shows the following error:
  <a href="https://i.stack.imgur.com/vdqVr.png" rel="nofollow noreferrer">Error Image</a></p>