Skip to content

Instantly share code, notes, and snippets.

@swestcott
Created July 24, 2012 21:55
Show Gist options
  • Save swestcott/3172927 to your computer and use it in GitHub Desktop.
Save swestcott/3172927 to your computer and use it in GitHub Desktop.
Behat Multi Session - Use Chat Room
<?php
/**
* @When /^"([^"]*)" posts a message$/
*/
public function postsAMessage($user)
{
// Ensure message is unique
$this->message = 'Selenium Test ' . microtime(true);
$this->getSession($user)->getPage()->fillField("chat", $this->message);
$this->getSession($user)->executeScript(
"$('form').submit();"
);
$this->assertSession($user)->pageTextContains($this->message);
}
/**
* @Then /^"([^"]*)" should see that message$/
*/
public function shouldSeeThatMessage($user)
{
$this->getSession($user)->wait(self::MAX_WAIT,
"$('.them:contains(\"" . $this->message . "\")').size() == 1"
);
$this->assertSession($user)->pageTextContains($this->message);
$node = $this->getSession($user)->getPage()->find("css", ".them");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment