A handful of generic helper and utility methods for Codeception.
- seeLinkInSelector/dontSeeLinkInSelector - looks for a link in a particular CSS or XPath selector.
- seeElementHasStyle/dontSeeElementHasStyle - see an element has been applied a style. Allows you to check a single element has a CSS style assigned, e.g. you can check that ".icon-r" class is floated right. Requires WebDriver.
- seeRegexInSource/dontSeeRegexInSource - see page source matches a regular expression.
- fillCkEditor - Fill a CKEditor WYSIWYG field.
- grabCkEditorValue - Grab the current value of the CKEditor field.
- seeInCkEditor/dontSeeInCkEditor - see specified text inside a CKEditor instance.
Add to your composer.json, e.g.
{
"repositories": [
{
"type":"vcs",
"url":"[email protected]:ixis/codeception-utilities.git"
}
],
"require": {
"ixis/codeception-utilities": "dev-develop"
}
}
modules:
enabled:
- CodeceptionUtilities
- CodeceptionCkEditorUtilities
// See a link with title and URL as specified in the element selected by "#content #footer".
$I->seeLinkInSelector("Facebook", "https://www.facebook.com/", "#content #footer");
// See the element selected by "#footer .icon-r" has the float:right style applied.
$I->seeElementHasStyle("#footer .icon-r", "float", "right");
// Set the ckeditor with id "editor1" to "<p>hello world</p>"
$I->fillCkEditor("editor1", "<p>hello world</p>");
// Grab the current value of the ckeditor field and assert it contains "hello"
$value = $I->grabCkEditorValue("editor1");
PHPUnit_Framework_Assert::assertContains("hello", $value);
// or, if using Asserts Codeception module:
$I->assertContains("hello", $value)