From 0d96ed312ae03bece59169bf203e6cd149c96c38 Mon Sep 17 00:00:00 2001 From: Yarik Date: Mon, 25 Apr 2016 16:52:03 +0300 Subject: [PATCH] test --- tests/_support/_generated/AcceptanceTesterActions.php | 2088 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- tests/_support/_generated/FunctionalTesterActions.php | 2 +- tests/_support/_generated/UnitTesterActions.php | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- tests/acceptance.suite.yml | 2 +- 4 files changed, 940 insertions(+), 1314 deletions(-) diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php index d10dae5..90a76e6 100644 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ b/tests/_support/_generated/AcceptanceTesterActions.php @@ -1,11 +1,11 @@ -getScenario()->runStep(new \Codeception\Step\Action('debugWebDriverLogs', func_get_args())); + public function setHeader($name, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Changes the subdomain for the 'url' configuration parameter. - * Does not open a page; use `amOnPage` for that. - * - * ``` php - * amOnSubdomain('user'); - * $I->amOnPage('/'); - * // moves to http://user.mysite.com/ - * ?> - * ``` - * - * @param $subdomain + * Authenticates user for HTTP_AUTH * - * @return mixed - * @see \Codeception\Module\WebDriver::amOnSubdomain() + * @param $username + * @param $password + * @see \Codeception\Module\PhpBrowser::amHttpAuthenticated() */ - public function amOnSubdomain($subdomain) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); + public function amHttpAuthenticated($username, $password) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Takes a screenshot of the current window and saves it to `tests/_output/debug`. + * Open web page at the given absolute URL and sets its hostname as the base host. * * ``` php * amOnPage('/user/edit'); - * $I->makeScreenshot('edit_page'); - * // saved to: tests/_output/debug/edit_page.png + * $I->amOnUrl('http://codeception.com'); + * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart * ?> * ``` - * - * @param $name - * @see \Codeception\Module\WebDriver::makeScreenshot() + * @see \Codeception\Module\PhpBrowser::amOnUrl() */ - public function makeScreenshot($name) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('makeScreenshot', func_get_args())); + public function amOnUrl($url) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Resize the current window. + * Changes the subdomain for the 'url' configuration parameter. + * Does not open a page; use `amOnPage` for that. * * ``` php * resizeWindow(800, 600); - * - * ``` - * - * @param int $width - * @param int $height - * @see \Codeception\Module\WebDriver::resizeWindow() - */ - public function resizeWindow($width, $height) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('resizeWindow', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * // If config is: 'http://mysite.com' + * // or config is: 'http://www.mysite.com' + * // or config is: 'http://company.mysite.com' * - * ``` php - * seeCookie('PHPSESSID'); + * $I->amOnSubdomain('user'); + * $I->amOnPage('/'); + * // moves to http://user.mysite.com/ * ?> * ``` * - * @param $cookie - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCookie() - */ - public function canSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that a cookie with the given name is set. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * ``` php - * seeCookie('PHPSESSID'); - * ?> - * ``` + * @param $subdomain * - * @param $cookie - * @param array $params * @return mixed - * @see \Codeception\Module\WebDriver::seeCookie() + * @see \Codeception\Module\PhpBrowser::amOnSubdomain() */ - public function seeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); + public function amOnSubdomain($subdomain) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCookie() - */ - public function cantSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there isn't a cookie with the given name. - * You can set additional cookie params like `domain`, `path` as array passed in last argument. - * - * @param $cookie - * - * @param array $params - * @return mixed - * @see \Codeception\Module\WebDriver::dontSeeCookie() - */ - public function dontSeeCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. + * Low-level API method. + * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly * - * Sets a cookie with the given name and value. - * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument. + * Example: * * ``` php * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); + * $I->executeInGuzzle(function (\GuzzleHttp\Client $client) { + * $client->get('/get', ['query' => ['foo' => 'bar']]); + * }); * ?> * ``` * - * @param $name - * @param $val - * @param array $params + * It is not recommended to use this command on a regular basis. + * If Codeception lacks important Guzzle Client methods, implement them and submit patches. * - * @return mixed - * @see \Codeception\Module\WebDriver::setCookie() + * @param callable $function + * @see \Codeception\Module\PhpBrowser::executeInGuzzle() */ - public function setCookie($cookie, $value, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); + public function executeInGuzzle($function) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Unsets cookie with the given name. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * Sets the HTTP header to the passed value - which is used on + * subsequent HTTP requests through PhpBrowser. * - * @param $cookie + * Example: + * ```php + * setHeader('X-Requested-With', 'Codeception'); + * $I->amOnPage('test-headers.php'); + * ?> + * ``` * - * @param array $params - * @return mixed - * @see \Codeception\Module\WebDriver::resetCookie() + * @param string $name the name of the request header + * @param string $value the value to set it to for subsequent + * requests + * @see \Codeception\Lib\InnerBrowser::haveHttpHeader() */ - public function resetCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); + public function haveHttpHeader($name, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('haveHttpHeader', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Grabs a cookie value. - * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * Deletes the header with the passed name. Subsequent requests + * will not have the deleted header in its request. * - * @param $cookie + * Example: + * ```php + * haveHttpHeader('X-Requested-With', 'Codeception'); + * $I->amOnPage('test-headers.php'); + * // ... + * $I->deleteHeader('X-Requested-With'); + * $I->amOnPage('some-other-page.php'); + * ?> + * ``` * - * @param array $params - * @return mixed - * @see \Codeception\Module\WebDriver::grabCookie() + * @param string $name the name of the header to delete. + * @see \Codeception\Lib\InnerBrowser::deleteHeader() */ - public function grabCookie($cookie, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); + public function deleteHeader($name) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Open web page at the given absolute URL and sets its hostname as the base host. + * Opens the page for the given relative URI. * * ``` php * amOnUrl('http://codeception.com'); - * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart - * ?> + * // opens front page + * $I->amOnPage('/'); + * // opens /register page + * $I->amOnPage('/register'); * ``` - * @see \Codeception\Module\WebDriver::amOnUrl() + * + * @param $page + * @see \Codeception\Lib\InnerBrowser::amOnPage() */ - public function amOnUrl($url) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); + public function amOnPage($page) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Opens the page for the given relative URI. + * Perform a click on a link or a button, given by a locator. + * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. + * For buttons, the "value" attribute, "name" attribute, and inner text are searched. + * For links, the link text is searched. + * For images, the "alt" attribute and inner text of any parent links are searched. + * + * The second parameter is a context (CSS or XPath locator) to narrow the search. + * + * Note that if the locator matches a button of type `submit`, the form will be submitted. * * ``` php * amOnPage('/'); - * // opens /register page - * $I->amOnPage('/register'); + * // simple link + * $I->click('Logout'); + * // button of form + * $I->click('Submit'); + * // CSS button + * $I->click('#form input[type=submit]'); + * // XPath + * $I->click('//form/*[@type=submit]'); + * // link in context + * $I->click('Logout', '#nav'); + * // using strict locator + * $I->click(['link' => 'Login']); + * ?> * ``` * - * @param $page - * @see \Codeception\Module\WebDriver::amOnPage() + * @param $link + * @param $context + * @see \Codeception\Lib\InnerBrowser::click() */ - public function amOnPage($page) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); + public function click($link, $context = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); } @@ -301,7 +258,7 @@ trait AcceptanceTesterActions * @param $text * @param null $selector * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::see() + * @see \Codeception\Lib\InnerBrowser::see() */ public function canSee($text, $selector = null) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); @@ -337,7 +294,7 @@ trait AcceptanceTesterActions * * @param $text * @param null $selector - * @see \Codeception\Module\WebDriver::see() + * @see \Codeception\Lib\InnerBrowser::see() */ public function see($text, $selector = null) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); @@ -374,7 +331,7 @@ trait AcceptanceTesterActions * @param $text * @param null $selector * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSee() + * @see \Codeception\Lib\InnerBrowser::dontSee() */ public function cantSee($text, $selector = null) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); @@ -408,7 +365,7 @@ trait AcceptanceTesterActions * * @param $text * @param null $selector - * @see \Codeception\Module\WebDriver::dontSee() + * @see \Codeception\Lib\InnerBrowser::dontSee() */ public function dontSee($text, $selector = null) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); @@ -428,7 +385,7 @@ trait AcceptanceTesterActions * * @param $raw * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInSource() + * @see \Codeception\Lib\InnerBrowser::seeInSource() */ public function canSeeInSource($raw) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args())); @@ -445,7 +402,7 @@ trait AcceptanceTesterActions * ``` * * @param $raw - * @see \Codeception\Module\WebDriver::seeInSource() + * @see \Codeception\Lib\InnerBrowser::seeInSource() */ public function seeInSource($raw) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args())); @@ -465,7 +422,7 @@ trait AcceptanceTesterActions * * @param $raw * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInSource() + * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() */ public function cantSeeInSource($raw) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args())); @@ -482,7 +439,7 @@ trait AcceptanceTesterActions * ``` * * @param $raw - * @see \Codeception\Module\WebDriver::dontSeeInSource() + * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() */ public function dontSeeInSource($raw) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args())); @@ -492,192 +449,93 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the page source contains the given string. + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. * - * ```php + * ``` php * seeInPageSource('seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> * ``` * - * @param $text + * @param $text + * @param null $url * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInPageSource() + * @see \Codeception\Lib\InnerBrowser::seeLink() */ - public function canSeeInPageSource($text) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInPageSource', func_get_args())); + public function canSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the page source contains the given string. + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. * - * ```php + * ``` php * seeInPageSource('seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> * ``` * - * @param $text - * @see \Codeception\Module\WebDriver::seeInPageSource() + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::seeLink() */ - public function seeInPageSource($text) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInPageSource', func_get_args())); + public function seeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the page source doesn't contain the given string. + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` * * @param $text + * @param null $url * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInPageSource() + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() */ - public function cantSeeInPageSource($text) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInPageSource', func_get_args())); + public function cantSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the page source doesn't contain the given string. + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` * * @param $text - * @see \Codeception\Module\WebDriver::dontSeeInPageSource() + * @param null $url + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() */ - public function dontSeeInPageSource($text) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInPageSource', func_get_args())); + public function dontSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Perform a click on a link or a button, given by a locator. - * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. - * For buttons, the "value" attribute, "name" attribute, and inner text are searched. - * For links, the link text is searched. - * For images, the "alt" attribute and inner text of any parent links are searched. - * - * The second parameter is a context (CSS or XPath locator) to narrow the search. - * - * Note that if the locator matches a button of type `submit`, the form will be submitted. - * - * ``` php - * click('Logout'); - * // button of form - * $I->click('Submit'); - * // CSS button - * $I->click('#form input[type=submit]'); - * // XPath - * $I->click('//form/*[@type=submit]'); - * // link in context - * $I->click('Logout', '#nav'); - * // using strict locator - * $I->click(['link' => 'Login']); - * ?> - * ``` - * - * @param $link - * @param $context - * @see \Codeception\Module\WebDriver::click() - */ - public function click($link, $context = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeLink() - */ - public function canSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there's a link with the specified text. - * Give a full URL as the second parameter to match links with that exact URL. - * - * ``` php - * seeLink('Logout'); // matches Logout - * $I->seeLink('Logout','/logout'); // matches Logout - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Module\WebDriver::seeLink() - */ - public function seeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param $text - * @param null $url - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeLink() - */ - public function cantSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page doesn't contain a link with the given string. - * If the second parameter is given, only links with a matching "href" attribute will be checked. - * - * ``` php - * dontSeeLink('Logout'); // I suppose user is not logged in - * $I->dontSeeLink('Checkout now', '/store/cart.php'); - * ?> - * ``` - * - * @param $text - * @param null $url - * @see \Codeception\Module\WebDriver::dontSeeLink() - */ - public function dontSeeLink($text, $url = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that current URI contains the given string. + * Checks that current URI contains the given string. * * ``` php * getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); @@ -710,7 +568,7 @@ trait AcceptanceTesterActions * ``` * * @param $uri - * @see \Codeception\Module\WebDriver::seeInCurrentUrl() + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() */ public function seeInCurrentUrl($uri) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); @@ -720,158 +578,158 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. + * Checks that the current URI doesn't contain the given string. * * ``` php * seeCurrentUrlEquals('/'); + * $I->dontSeeInCurrentUrl('/users/'); * ?> * ``` * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals() + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() */ - public function canSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); + public function cantSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URL is equal to the given string. - * Unlike `seeInCurrentUrl`, this only matches the full URL. + * Checks that the current URI doesn't contain the given string. * * ``` php * seeCurrentUrlEquals('/'); + * $I->dontSeeInCurrentUrl('/users/'); * ?> * ``` * * @param $uri - * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals() + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() */ - public function seeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); + public function dontSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URL matches the given regular expression. + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. * * ``` php * seeCurrentUrlMatches('~$/users/(\d+)~'); + * $I->seeCurrentUrlEquals('/'); * ?> * ``` * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches() + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() */ - public function canSeeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); + public function canSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URL matches the given regular expression. + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. * * ``` php * seeCurrentUrlMatches('~$/users/(\d+)~'); + * $I->seeCurrentUrlEquals('/'); * ?> * ``` * * @param $uri - * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches() + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() */ - public function seeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); + public function seeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URI doesn't contain the given string. + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. * * ``` php * dontSeeInCurrentUrl('/users/'); + * // current url is not root + * $I->dontSeeCurrentUrlEquals('/'); * ?> * ``` * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl() + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() */ - public function cantSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); + public function cantSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URI doesn't contain the given string. + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. * * ``` php * dontSeeInCurrentUrl('/users/'); + * // current url is not root + * $I->dontSeeCurrentUrlEquals('/'); * ?> * ``` * * @param $uri - * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl() + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() */ - public function dontSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); + public function dontSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * Checks that the current URL matches the given regular expression. * * ``` php * dontSeeCurrentUrlEquals('/'); + * // to match root url + * $I->seeCurrentUrlMatches('~$/users/(\d+)~'); * ?> * ``` * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals() + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() */ - public function cantSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); + public function canSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the current URL doesn't equal the given string. - * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * Checks that the current URL matches the given regular expression. * * ``` php * dontSeeCurrentUrlEquals('/'); + * // to match root url + * $I->seeCurrentUrlMatches('~$/users/(\d+)~'); * ?> * ``` * * @param $uri - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals() + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() */ - public function dontSeeCurrentUrlEquals($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); + public function seeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); } @@ -889,7 +747,7 @@ trait AcceptanceTesterActions * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() */ public function cantSeeCurrentUrlMatches($uri) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); @@ -907,7 +765,7 @@ trait AcceptanceTesterActions * ``` * * @param $uri - * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() */ public function dontSeeCurrentUrlMatches($uri) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); @@ -930,7 +788,7 @@ trait AcceptanceTesterActions * @param null $uri * * @return mixed - * @see \Codeception\Module\WebDriver::grabFromCurrentUrl() + * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() */ public function grabFromCurrentUrl($uri = null) { return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); @@ -952,7 +810,7 @@ trait AcceptanceTesterActions * * @param $checkbox * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() */ public function canSeeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); @@ -971,7 +829,7 @@ trait AcceptanceTesterActions * ``` * * @param $checkbox - * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() */ public function seeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); @@ -992,7 +850,7 @@ trait AcceptanceTesterActions * * @param $checkbox * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() */ public function cantSeeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); @@ -1010,7 +868,7 @@ trait AcceptanceTesterActions * ``` * * @param $checkbox - * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() */ public function dontSeeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); @@ -1037,7 +895,7 @@ trait AcceptanceTesterActions * @param $field * @param $value * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInField() + * @see \Codeception\Lib\InnerBrowser::seeInField() */ public function canSeeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); @@ -1061,7 +919,7 @@ trait AcceptanceTesterActions * * @param $field * @param $value - * @see \Codeception\Module\WebDriver::seeInField() + * @see \Codeception\Lib\InnerBrowser::seeInField() */ public function seeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); @@ -1088,7 +946,7 @@ trait AcceptanceTesterActions * @param $field * @param $value * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInField() + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() */ public function cantSeeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); @@ -1112,7 +970,7 @@ trait AcceptanceTesterActions * * @param $field * @param $value - * @see \Codeception\Module\WebDriver::dontSeeInField() + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() */ public function dontSeeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); @@ -1182,7 +1040,7 @@ trait AcceptanceTesterActions * @param $formSelector * @param $params * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInFormFields() + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() */ public function canSeeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); @@ -1249,7 +1107,7 @@ trait AcceptanceTesterActions * * @param $formSelector * @param $params - * @see \Codeception\Module\WebDriver::seeInFormFields() + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() */ public function seeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); @@ -1299,7 +1157,7 @@ trait AcceptanceTesterActions * @param $formSelector * @param $params * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInFormFields() + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() */ public function cantSeeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); @@ -1346,7 +1204,7 @@ trait AcceptanceTesterActions * * @param $formSelector * @param $params - * @see \Codeception\Module\WebDriver::dontSeeInFormFields() + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() */ public function dontSeeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); @@ -1356,100 +1214,277 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Selects an option in a select tag or in radio button group. + * Submits the given form on the page, optionally with the given form + * values. Pass the form field's values as an array in the second + * parameter. * - * ``` php - * selectOption('form select[name=account]', 'Premium'); - * $I->selectOption('form input[name=payment]', 'Monthly'); - * $I->selectOption('//form/select[@name=account]', 'Monthly'); - * ?> - * ``` + * Although this function can be used as a short-hand version of + * `fillField()`, `selectOption()`, `click()` etc. it has some important + * differences: + * + * * Only field *names* may be used, not CSS/XPath selectors nor field labels + * * If a field is sent to this function that does *not* exist on the page, + * it will silently be added to the HTTP request. This is helpful for testing + * some types of forms, but be aware that you will *not* get an exception + * like you would if you called `fillField()` or `selectOption()` with + * a missing field. + * + * Fields that are not provided will be filled by their values from the page, + * or from any previous calls to `fillField()`, `selectOption()` etc. + * You don't need to click the 'Submit' button afterwards. + * This command itself triggers the request to form's action. * - * Provide an array for the second argument to select multiple options: + * You can optionally specify which button's value to include + * in the request with the last parameter (as an alternative to + * explicitly setting its value in the second parameter), as + * button values are not otherwise included in the request. + * + * Examples: * * ``` php * selectOption('Which OS do you use?', array('Windows','Linux')); - * ?> - * ``` + * $I->submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ]); + * // or + * $I->submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ], 'submitButtonName'); * - * @param $select - * @param $option - * @see \Codeception\Module\WebDriver::selectOption() - */ - public function selectOption($select, $option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. + * ``` * + * For example, given this sample "Sign Up" form: * - * @see \Codeception\Module\WebDriver::unselectOption() - */ - public function unselectOption($select, $option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('unselectOption', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. + * ``` html + *
+ * Login: + *
+ * Password: + *
+ * Do you agree to our terms? + *
+ * Select pricing plan: + * + * + *
+ * ``` * - * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. + * You could write the following to submit it: * * ``` php * checkOption('#agree'); - * ?> - * ``` - * - * @param $option - * @see \Codeception\Module\WebDriver::checkOption() + * $I->submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ], + * 'submitButton' + * ); + * ``` + * Note that "2" will be the submitted value for the "plan" field, as it is + * the selected option. + * + * You can also emulate a JavaScript submission by not specifying any + * buttons in the third parameter to submitForm. + * + * ```php + * submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ] + * ); + * ``` + * + * This function works well when paired with `seeInFormFields()` + * for quickly testing CRUD interfaces and form validation logic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('#my-form', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('#my-form', $form); + * ``` + * + * Parameter values can be set to arrays for multiple input fields + * of the same name, or multi-select combo boxes. For checkboxes, + * you can use either the string value or boolean `true`/`false` which will + * be replaced by the checkbox's value in the DOM. + * + * ``` php + * submitForm('#my-form', [ + * 'field1' => 'value', + * 'checkbox' => [ + * 'value of first checkbox', + * 'value of second checkbox', + * ], + * 'otherCheckboxes' => [ + * true, + * false, + * false + * ], + * 'multiselect' => [ + * 'first option value', + * 'second option value' + * ] + * ]); + * ``` + * + * Mixing string and boolean values for a checkbox's value is not supported + * and may produce unexpected results. + * + * Field names ending in `[]` must be passed without the trailing square + * bracket characters, and must contain an array for its value. This allows + * submitting multiple values with the same name, consider: + * + * ```php + * submitForm('#my-form', [ + * 'field[]' => 'value', + * 'field[]' => 'another value', // 'field[]' is already a defined key + * ]); + * ``` + * + * The solution is to pass an array value: + * + * ```php + * submitForm('#my-form', [ + * 'field' => [ + * 'value', + * 'another value', + * ] + * ]); + * ``` + * + * @param $selector + * @param $params + * @param $button + * @see \Codeception\Lib\InnerBrowser::submitForm() */ - public function checkOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); + public function submitForm($selector, $params, $button = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Unticks a checkbox. + * Fills a text field or textarea with the given string. * * ``` php * uncheckOption('#notify'); + * $I->fillField("//input[@type='text']", "Hello World!"); + * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::fillField() + */ + public function fillField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Selects an option in a select tag or in radio button group. + * + * ``` php + * selectOption('form select[name=account]', 'Premium'); + * $I->selectOption('form input[name=payment]', 'Monthly'); + * $I->selectOption('//form/select[@name=account]', 'Monthly'); * ?> * ``` * + * Provide an array for the second argument to select multiple options: + * + * ``` php + * selectOption('Which OS do you use?', array('Windows','Linux')); + * ?> + * ``` + * + * Or provide an associative array for the second argument to specifically define which selection method should be used: + * + * ``` php + * selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' + * $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' + * ?> + + ``` + * + * @param $select * @param $option - * @see \Codeception\Module\WebDriver::uncheckOption() + * @see \Codeception\Lib\InnerBrowser::selectOption() */ - public function uncheckOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); + public function selectOption($select, $option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Fills a text field or textarea with the given string. + * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. * * ``` php * fillField("//input[@type='text']", "Hello World!"); - * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * $I->checkOption('#agree'); * ?> * ``` * - * @param $field - * @param $value - * @see \Codeception\Module\WebDriver::fillField() + * @param $option + * @see \Codeception\Lib\InnerBrowser::checkOption() */ - public function fillField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); + public function checkOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unticks a checkbox. + * + * ``` php + * uncheckOption('#notify'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::uncheckOption() + */ + public function uncheckOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); } @@ -1467,7 +1502,7 @@ trait AcceptanceTesterActions * * @param $field * @param $filename - * @see \Codeception\Module\WebDriver::attachFile() + * @see \Codeception\Lib\InnerBrowser::attachFile() */ public function attachFile($field, $filename) { return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); @@ -1477,13 +1512,71 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Grabs all visible text from the current page. + * If your page triggers an ajax request, you can perform it manually. + * This action sends a GET ajax request with specified params. + * + * See ->sendAjaxPostRequest for examples. + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() + */ + public function sendAjaxGetRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends a POST ajax request with specified params. + * Additional params can be passed as array. + * + * Example: + * + * Imagine that by clicking checkbox you trigger ajax request which updates user settings. + * We emulate that click by running this ajax request manually. + * + * ``` php + * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST + * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET + * + * ``` + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() + */ + public function sendAjaxPostRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends an ajax request with specified method and params. + * + * Example: + * + * You need to perform an ajax request specifying the HTTP method. * - * @return string - * @see \Codeception\Module\WebDriver::getVisibleText() + * ``` php + * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); + * + * ``` + * + * @param $method + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() */ - public function getVisibleText() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getVisibleText', func_get_args())); + public function sendAjaxRequest($method, $uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); } @@ -1504,7 +1597,7 @@ trait AcceptanceTesterActions * @param $cssOrXPathOrRegex * * @return mixed - * @see \Codeception\Module\WebDriver::grabTextFrom() + * @see \Codeception\Lib\InnerBrowser::grabTextFrom() */ public function grabTextFrom($cssOrXPathOrRegex) { return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); @@ -1528,7 +1621,7 @@ trait AcceptanceTesterActions * @param $attribute * * @return mixed - * @see \Codeception\Module\WebDriver::grabAttributeFrom() + * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() */ public function grabAttributeFrom($cssOrXpath, $attribute) { return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); @@ -1538,31 +1631,6 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Finds the value for the given form field. - * If a fuzzy locator is used, the field is found by field name, CSS, and XPath. - * - * ``` php - * grabValueFrom('Name'); - * $name = $I->grabValueFrom('input[name=username]'); - * $name = $I->grabValueFrom('descendant-or-self::form/descendant::input[@name = 'username']'); - * $name = $I->grabValueFrom(['name' => 'username']); - * ?> - * ``` - * - * @param $field - * - * @return mixed - * @see \Codeception\Module\WebDriver::grabValueFrom() - */ - public function grabValueFrom($field) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * * Grabs either the text content, or attribute values, of nodes * matched by $cssOrXpath and returns them as an array. * @@ -1585,7 +1653,7 @@ trait AcceptanceTesterActions * @param $cssOrXpath * @param $attribute * @return string[] - * @see \Codeception\Module\WebDriver::grabMultiple() + * @see \Codeception\Lib\InnerBrowser::grabMultiple() */ public function grabMultiple($cssOrXpath, $attribute = null) { return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args())); @@ -1595,1092 +1663,534 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. - * - * ``` php - * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); - * ?> - * ``` + * @param $field * - * @param $selector - * @param array $attributes - * @return - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeElement() + * @return array|mixed|null|string + * @see \Codeception\Lib\InnerBrowser::grabValueFrom() */ - public function canSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); + public function grabValueFrom($field) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); } + + /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the given element exists on the page and is visible. - * You can also specify expected attributes of this element. + * Sets a cookie with the given name and value. + * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument. * * ``` php * seeElement('.error'); - * $I->seeElement('//form/input[1]'); - * $I->seeElement('input', ['name' => 'login']); - * $I->seeElement('input', ['value' => '123456']); - * - * // strict locator in first arg, attributes in second - * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * $I->setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); * ?> * ``` * - * @param $selector - * @param array $attributes - * @return - * @see \Codeception\Module\WebDriver::seeElement() - */ - public function seeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeElement() - */ - public function cantSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element is invisible or not present on the page. - * You can also specify expected attributes of this element. - * - * ``` php - * dontSeeElement('.error'); - * $I->dontSeeElement('//form/input[1]'); - * $I->dontSeeElement('input', ['name' => 'login']); - * $I->dontSeeElement('input', ['value' => '123456']); - * ?> - * ``` - * - * @param $selector - * @param array $attributes - * @see \Codeception\Module\WebDriver::dontSeeElement() - */ - public function dontSeeElement($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page, even it is invisible. - * - * ``` php - * seeElementInDOM('//form/input[type=hidden]'); - * ?> - * ``` - * - * @param $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeElementInDOM() - */ - public function canSeeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElementInDOM', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given element exists on the page, even it is invisible. - * - * ``` php - * seeElementInDOM('//form/input[type=hidden]'); - * ?> - * ``` - * - * @param $selector - * @see \Codeception\Module\WebDriver::seeElementInDOM() - */ - public function seeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElementInDOM', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opposite of `seeElementInDOM`. - * - * @param $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeElementInDOM() - */ - public function cantSeeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElementInDOM', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Opposite of `seeElementInDOM`. - * - * @param $selector - * @see \Codeception\Module\WebDriver::dontSeeElementInDOM() - */ - public function dontSeeElementInDOM($selector, $attributes = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElementInDOM', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected : - * - string: strict number - * - array: range of numbers [0,10] - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeNumberOfElements() - */ - public function canSeeNumberOfElements($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that there are a certain number of elements matched by the given locator on the page. - * - * ``` php - * seeNumberOfElements('tr', 10); - * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements - * ?> - * ``` - * @param $selector - * @param mixed $expected : - * - string: strict number - * - array: range of numbers [0,10] - * @see \Codeception\Module\WebDriver::seeNumberOfElements() - */ - public function seeNumberOfElements($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM() - */ - public function canSeeNumberOfElementsInDOM($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElementsInDOM', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM() - */ - public function seeNumberOfElementsInDOM($selector, $expected) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElementsInDOM', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeOptionIsSelected() - */ - public function canSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is selected. - * - * ``` php - * seeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText + * @param $name + * @param $val + * @param array $params * * @return mixed - * @see \Codeception\Module\WebDriver::seeOptionIsSelected() + * @see \Codeception\Lib\InnerBrowser::setCookie() */ - public function seeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); + public function setCookie($name, $val, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` - * - * @param $selector - * @param $optionText - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeOptionIsSelected() - */ - public function cantSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the given option is not selected. - * - * ``` php - * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); - * ?> - * ``` + * Grabs a cookie value. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. * - * @param $selector - * @param $optionText + * @param $cookie * + * @param array $params * @return mixed - * @see \Codeception\Module\WebDriver::dontSeeOptionIsSelected() + * @see \Codeception\Lib\InnerBrowser::grabCookie() */ - public function dontSeeOptionIsSelected($selector, $optionText) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); + public function grabCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the page title contains the given string. + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * ``` php * seeInTitle('Blog - Post #1'); + * $I->seeCookie('PHPSESSID'); * ?> * ``` * - * @param $title - * + * @param $cookie + * @param array $params * @return mixed * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInTitle() + * @see \Codeception\Lib\InnerBrowser::seeCookie() */ - public function canSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); + public function canSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the page title contains the given string. + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * * ``` php * seeInTitle('Blog - Post #1'); + * $I->seeCookie('PHPSESSID'); * ?> * ``` * - * @param $title - * - * @return mixed - * @see \Codeception\Module\WebDriver::seeInTitle() - */ - public function seeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * - * @return mixed - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::dontSeeInTitle() - */ - public function cantSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the page title does not contain the given string. - * - * @param $title - * + * @param $cookie + * @param array $params * @return mixed - * @see \Codeception\Module\WebDriver::dontSeeInTitle() - */ - public function dontSeeInTitle($title) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Accepts the active JavaScript native popup window, as created by `window.alert`|`window.confirm`|`window.prompt`. - * Don't confuse popups with modal windows, as created by [various libraries](http://jster.net/category/windows-modals-popups). - * @see \Codeception\Module\WebDriver::acceptPopup() - */ - public function acceptPopup() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('acceptPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Dismisses the active JavaScript popup, as created by `window.alert`|`window.confirm`|`window.prompt`. - * @see \Codeception\Module\WebDriver::cancelPopup() - */ - public function cancelPopup() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('cancelPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the active JavaScript popup, as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. - * - * @param $text - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Module\WebDriver::seeInPopup() - */ - public function canSeeInPopup($text) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInPopup', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the active JavaScript popup, as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. - * - * @param $text - * @see \Codeception\Module\WebDriver::seeInPopup() - */ - public function seeInPopup($text) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Enters text into a native JavaScript prompt popup, as created by `window.prompt`. - * - * @param $keys - * @see \Codeception\Module\WebDriver::typeInPopup() - */ - public function typeInPopup($keys) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('typeInPopup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Reloads the current page. - * @see \Codeception\Module\WebDriver::reloadPage() + * @see \Codeception\Lib\InnerBrowser::seeCookie() */ - public function reloadPage() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('reloadPage', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Moves back in history. - * @see \Codeception\Module\WebDriver::moveBack() - */ - public function moveBack() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('moveBack', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Moves forward in history. - * @see \Codeception\Module\WebDriver::moveForward() - */ - public function moveForward() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('moveForward', func_get_args())); + public function seeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Submits the given form on the page, optionally with the given form - * values. Give the form fields values as an array. Note that hidden fields - * can't be accessed. - * - * Skipped fields will be filled by their values from the page. - * You don't need to click the 'Submit' button afterwards. - * This command itself triggers the request to form's action. - * - * You can optionally specify what button's value to include - * in the request with the last parameter as an alternative to - * explicitly setting its value in the second parameter, as - * button values are not otherwise included in the request. - * - * Examples: - * - * ``` php - * submitForm('#login', [ - * 'login' => 'davert', - * 'password' => '123456' - * ]); - * // or - * $I->submitForm('#login', [ - * 'login' => 'davert', - * 'password' => '123456' - * ], 'submitButtonName'); - * - * ``` - * - * For example, given this sample "Sign Up" form: - * - * ``` html - *
- * Login: - *
- * Password: - *
- * Do you agree to our terms? - *
- * Select pricing plan: - * - * - *
- * ``` - * - * You could write the following to submit it: - * - * ``` php - * submitForm( - * '#userForm', - * [ - * 'user[login]' => 'Davert', - * 'user[password]' => '123456', - * 'user[agree]' => true - * ], - * 'submitButton' - * ); - * ``` - * Note that "2" will be the submitted value for the "plan" field, as it is - * the selected option. - * - * Also note that this differs from PhpBrowser, in that - * ```'user' => [ 'login' => 'Davert' ]``` is not supported at the moment. - * Named array keys *must* be included in the name as above. - * - * Pair this with seeInFormFields for quick testing magic. - * - * ``` php - * 'value', - * 'field2' => 'another value', - * 'checkbox1' => true, - * // ... - * ]; - * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); - * // $I->amOnPage('/path/to/form-page') may be needed - * $I->seeInFormFields('//form[@id=my-form]', $form); - * ?> - * ``` - * - * Parameter values must be set to arrays for multiple input fields - * of the same name, or multi-select combo boxes. For checkboxes, - * either the string value can be used, or boolean values which will - * be replaced by the checkbox's value in the DOM. - * - * ``` php - * submitForm('#my-form', [ - * 'field1' => 'value', - * 'checkbox' => [ - * 'value of first checkbox', - * 'value of second checkbox, - * ], - * 'otherCheckboxes' => [ - * true, - * false, - * false - * ], - * 'multiselect' => [ - * 'first option value', - * 'second option value' - * ] - * ]); - * ?> - * ``` - * - * Mixing string and boolean values for a checkbox's value is not supported - * and may produce unexpected results. - * - * Field names ending in "[]" must be passed without the trailing square - * bracket characters, and must contain an array for its value. This allows - * submitting multiple values with the same name, consider: - * - * ```php - * $I->submitForm('#my-form', [ - * 'field[]' => 'value', - * 'field[]' => 'another value', // 'field[]' is already a defined key - * ]); - * ``` + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * - * The solution is to pass an array value: + * @param $cookie * - * ```php - * // this way both values are submitted - * $I->submitForm('#my-form', [ - * 'field' => [ - * 'value', - * 'another value', - * ] - * ]); - * ``` - * @param $selector - * @param $params - * @param $button - * @see \Codeception\Module\WebDriver::submitForm() + * @param array $params + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() */ - public function submitForm($selector, $params, $button = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); + public function cantSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); } - - /** * [!] Method is generated. Documentation taken from corresponding module. * - * Waits up to $timeout seconds for the given element to change. - * Element "change" is determined by a callback function which is called repeatedly until the return value evaluates to true. + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. * - * ``` php - * waitForElementChange('#menu', function(WebDriverElement $el) { - * return $el->isDisplayed(); - * }, 100); - * ?> - * ``` + * @param $cookie * - * @param $element - * @param \Closure $callback - * @param int $timeout seconds - * @throws \Codeception\Exception\ElementNotFound - * @see \Codeception\Module\WebDriver::waitForElementChange() + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() */ - public function waitForElementChange($element, $callback, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementChange', func_get_args())); + public function dontSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Waits up to $timeout seconds for an element to appear on the page. - * If the element doesn't appear, a timeout exception is thrown. + * Unsets cookie with the given name. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. * - * ``` php - * waitForElement('#agree_button', 30); // secs - * $I->click('#agree_button'); - * ?> - * ``` + * @param $cookie * - * @param $element - * @param int $timeout seconds - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForElement() + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::resetCookie() */ - public function waitForElement($element, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElement', func_get_args())); + public function resetCookie($name, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Waits up to $timeout seconds for the given element to be visible on the page. - * If element doesn't appear, a timeout exception is thrown. + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. * * ``` php * waitForElementVisible('#agree_button', 30); // secs - * $I->click('#agree_button'); + * $I->seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); * ?> * ``` * - * @param $element - * @param int $timeout seconds - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForElementVisible() + * @param $selector + * @param array $attributes + * @return + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeElement() */ - public function waitForElementVisible($element, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementVisible', func_get_args())); + public function canSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); } - - /** * [!] Method is generated. Documentation taken from corresponding module. * - * Waits up to $timeout seconds for the given element to become invisible. - * If element stays visible, a timeout exception is thrown. + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. * * ``` php * waitForElementNotVisible('#agree_button', 30); // secs + * $I->seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); * ?> * ``` * - * @param $element - * @param int $timeout seconds - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForElementNotVisible() + * @param $selector + * @param array $attributes + * @return + * @see \Codeception\Lib\InnerBrowser::seeElement() */ - public function waitForElementNotVisible($element, $timeout = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementNotVisible', func_get_args())); + public function seeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Waits up to $timeout seconds for the given string to appear on the page. - * Can also be passed a selector to search in. - * If the given text doesn't appear, a timeout exception is thrown. + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. * * ``` php * waitForText('foo', 30); // secs - * $I->waitForText('foo', 30, '.title'); // secs + * $I->dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); * ?> * ``` * - * @param string $text - * @param int $timeout seconds - * @param null $selector - * @throws \Exception - * @see \Codeception\Module\WebDriver::waitForText() - */ - public function waitForText($text, $timeout = null, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForText', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Wait for $timeout seconds. - * - * @param int $timeout secs - * @throws \Codeception\Exception\TestRuntimeException - * @see \Codeception\Module\WebDriver::wait() + * @param $selector + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() */ - public function wait($timeout) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('wait', func_get_args())); + public function cantSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); } - - /** * [!] Method is generated. Documentation taken from corresponding module. * - * Low-level API method. - * If Codeception commands are not enough, this allows you to use Selenium WebDriver methods directly: + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. * * ``` php - * $I->executeInSelenium(function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) { - * $webdriver->get('http://google.com'); - * }); + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> * ``` * - * This runs in the context of the [RemoteWebDriver class](https://github.com/facebook/php-webdriver/blob/master/lib/remote/RemoteWebDriver.php). - * Try not to use this command on a regular basis. - * If Codeception lacks a feature you need, please implement it and submit a patch. - * - * @param callable $function - * @see \Codeception\Module\WebDriver::executeInSelenium() + * @param $selector + * @param array $attributes + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() */ - public function executeInSelenium($function) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInSelenium', func_get_args())); + public function dontSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Switch to another window identified by name. - * - * The window can only be identified by name. If the $name parameter is blank, the parent window will be used. - * - * Example: - * ``` html - * - * ``` - * - * ``` php - * click("Open window"); - * # switch to another window - * $I->switchToWindow("another_window"); - * # switch to parent window - * $I->switchToWindow(); - * ?> - * ``` - * - * If the window has no name, the only way to access it is via the `executeInSelenium()` method, like so: + * Checks that there are a certain number of elements matched by the given locator on the page. * * ``` php * executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) { - * $handles=$webdriver->getWindowHandles(); - * $last_window = end($handles); - * $webdriver->switchTo()->window($last_window); - * }); + * $I->seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements * ?> * ``` - * - * @param string|null $name - * @see \Codeception\Module\WebDriver::switchToWindow() + * @param $selector + * @param mixed $expected : + * - string: strict number + * - array: range of numbers [0,10] + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() */ - public function switchToWindow($name = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToWindow', func_get_args())); + public function canSeeNumberOfElements($selector, $expected) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); } - - /** * [!] Method is generated. Documentation taken from corresponding module. * - * Switch to another frame on the page. - * - * Example: - * ``` html - *