Skip to content

Instantly share code, notes, and snippets.

@wouterj
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save wouterj/66b45c009fdea6b01a9e to your computer and use it in GitHub Desktop.

Select an option

Save wouterj/66b45c009fdea6b01a9e to your computer and use it in GitHub Desktop.
{
"require": {
"behat/mink-goutte-driver": "~1.0"
}
}
<!-- this page is http://localhost/some/form.php -->
<!doctype html>
<base href="http://localhost/">
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo 'Whoa!';
}
?>
<form action="#" method="POST">
<input type="submit" value="submit">
</form>
<?php
require 'vendor/autoload.php';
use Behat\Mink\Mink,
Behat\Mink\Session,
Behat\Mink\Driver\GoutteDriver,
Behat\Mink\Driver\Goutte\Client as GoutteClient;
$mink = new Mink(array(
'goutte' => new Session(new GoutteDriver(new GoutteClient())),
));
$session = $mink->getSession('goutte');
$session->visit('http://localhost/some/form.phtml');
$btn = $session->getPage()->findButton('submit');
$btn->click();
echo $session->getCurrentUrl(); // 'http://localhost#' should be 'http://localhost/some/form.phtml#'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment