diff --git a/README.md b/README.md index 76c2c7463e..ad93286975 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ https://github.com/Codeception/Verify $ vendor/bin/codecept run ``` +# Acceptance testing. + +You just need phantomjs installed. Tests are in /tests/acceptance. You can run tests with: +``` +$ vendor/bin/codecept run +``` # Stylus command stylus -w assets/css/src/*.styl -o assets/css/ diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php index 269b710dbc..b29b3602c4 100644 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ b/tests/_support/_generated/AcceptanceTesterActions.php @@ -1,11 +1,11 @@ -setHeader('X-Requested-With', 'Codeception'); - * $I->amOnPage('test-headers.php'); - * ?> - * ``` - * - * @param string $name the name of the request header - * @param string $value the value to set it to for subsequent - * requests - * @see \Codeception\Module\PhpBrowser::setHeader() - */ - 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. - * - * Deletes the header with the passed name. Subsequent requests - * will not have the deleted header in its request. - * - * Example: - * ```php - * setHeader('X-Requested-With', 'Codeception'); - * $I->amOnPage('test-headers.php'); - * // ... - * $I->deleteHeader('X-Requested-With'); - * $I->amOnPage('some-other-page.php'); - * ?> - * ``` - * - * @param string $name the name of the header to delete. - * @see \Codeception\Module\PhpBrowser::deleteHeader() - */ - public function deleteHeader($name) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Authenticates user for HTTP_AUTH - * - * @param $username - * @param $password - * @see \Codeception\Module\PhpBrowser::amHttpAuthenticated() - */ - 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. - * - * Open web page at the given absolute URL and sets its hostname as the base host. - * - * ``` php - * amOnUrl('http://codeception.com'); - * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart - * ?> - * ``` - * @see \Codeception\Module\PhpBrowser::amOnUrl() - */ - public function amOnUrl($url) { - return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); - } - - /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -118,7 +37,7 @@ trait AcceptanceTesterActions * @param $subdomain * * @return mixed - * @see \Codeception\Module\PhpBrowser::amOnSubdomain() + * @see \Codeception\Module\WebDriver::amOnSubdomain() */ public function amOnSubdomain($subdomain) { return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); @@ -128,27 +47,193 @@ trait AcceptanceTesterActions /** * [!] 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 - * - * Example: + * Takes a screenshot of the current window and saves it to `tests/_output/debug`. * * ``` php * executeInGuzzle(function (\GuzzleHttp\Client $client) { - * $client->get('/get', ['query' => ['foo' => 'bar']]); - * }); + * $I->amOnPage('/user/edit'); + * $I->makeScreenshot('edit_page'); + * // saved to: tests/_output/debug/edit_page.png * ?> * ``` * - * It is not recommended to use this command on a regular basis. - * If Codeception lacks important Guzzle Client methods, implement them and submit patches. - * - * @param callable $function - * @see \Codeception\Module\PhpBrowser::executeInGuzzle() + * @param $name + * @see \Codeception\Module\WebDriver::makeScreenshot() */ - public function executeInGuzzle($function) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); + public function makeScreenshot($name) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('makeScreenshot', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Resize the current window. + * + * ``` 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. + * + * ``` php + * seeCookie('PHPSESSID'); + * ?> + * ``` + * + * @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 $cookie + * @param array $params + * @return mixed + * @see \Codeception\Module\WebDriver::seeCookie() + */ + 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. + * + * 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. + * + * Sets a cookie with the given name and value. + * You can set additional cookie params like `domain`, `path`, `expire`, `secure` in array passed as last argument. + * + * ``` php + * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); + * ?> + * ``` + * + * @param $name + * @param $val + * @param array $params + * + * @return mixed + * @see \Codeception\Module\WebDriver::setCookie() + */ + public function setCookie($cookie, $value, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', 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. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Module\WebDriver::resetCookie() + */ + public function resetCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', 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. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Module\WebDriver::grabCookie() + */ + 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. + * + * Open web page at the given absolute URL and sets its hostname as the base host. + * + * ``` php + * amOnUrl('http://codeception.com'); + * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart + * ?> + * ``` + * @see \Codeception\Module\WebDriver::amOnUrl() + */ + public function amOnUrl($url) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); } @@ -167,13 +252,163 @@ trait AcceptanceTesterActions * ``` * * @param $page - * @see \Codeception\Lib\InnerBrowser::amOnPage() + * @see \Codeception\Module\WebDriver::amOnPage() */ public function amOnPage($page) { return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string. + * Specify a locator as the second parameter to match a specific region. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up','h1'); // I can suppose it's a signup page + * $I->see('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::see() + */ + public function canSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string. + * Specify a locator as the second parameter to match a specific region. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up','h1'); // I can suppose it's a signup page + * $I->see('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * @see \Codeception\Module\WebDriver::see() + */ + public function see($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified. + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSee() + */ + public function cantSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified. + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ?> + * ``` + * + * @param $text + * @param null $selector + * @see \Codeception\Module\WebDriver::dontSee() + */ + public function dontSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page source contains the given string. + * + * ```php + * seeInPageSource('getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInPageSource', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page source contains the given string. + * + * ```php + * seeInPageSource('getScenario()->runStep(new \Codeception\Step\Assertion('seeInPageSource', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page source doesn't contain the given string. + * + * @param $text + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeInPageSource() + */ + public function cantSeeInPageSource($text) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInPageSource', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page source doesn't contain the given string. + * + * @param $text + * @see \Codeception\Module\WebDriver::dontSeeInPageSource() + */ + public function dontSeeInPageSource($text) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInPageSource', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -206,103 +441,13 @@ trait AcceptanceTesterActions * * @param $link * @param $context - * @see \Codeception\Lib\InnerBrowser::click() + * @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 the current page contains the given string. - * Specify a locator as the second parameter to match a specific region. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up','h1'); // I can suppose it's a signup page - * $I->see('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function canSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page contains the given string. - * Specify a locator as the second parameter to match a specific region. - * - * ``` php - * see('Logout'); // I can suppose user is logged in - * $I->see('Sign Up','h1'); // I can suppose it's a signup page - * $I->see('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::see() - */ - public function see($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified. - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function cantSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); - } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current page doesn't contain the text specified. - * Give a locator as the second parameter to match a specific region. - * - * ```php - * dontSee('Login'); // I can suppose user is already logged in - * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page - * $I->dontSee('Sign Up','//body/h1'); // with XPath - * ?> - * ``` - * - * @param $text - * @param null $selector - * @see \Codeception\Lib\InnerBrowser::dontSee() - */ - public function dontSee($text, $selector = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); - } - - /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -319,7 +464,7 @@ trait AcceptanceTesterActions * @param $text * @param null $url * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeLink() + * @see \Codeception\Module\WebDriver::seeLink() */ public function canSeeLink($text, $url = null) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); @@ -339,7 +484,7 @@ trait AcceptanceTesterActions * * @param $text * @param null $url - * @see \Codeception\Lib\InnerBrowser::seeLink() + * @see \Codeception\Module\WebDriver::seeLink() */ public function seeLink($text, $url = null) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); @@ -362,7 +507,7 @@ trait AcceptanceTesterActions * @param $text * @param null $url * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + * @see \Codeception\Module\WebDriver::dontSeeLink() */ public function cantSeeLink($text, $url = null) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); @@ -382,7 +527,7 @@ trait AcceptanceTesterActions * * @param $text * @param null $url - * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + * @see \Codeception\Module\WebDriver::dontSeeLink() */ public function dontSeeLink($text, $url = null) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); @@ -405,7 +550,7 @@ trait AcceptanceTesterActions * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + * @see \Codeception\Module\WebDriver::seeInCurrentUrl() */ public function canSeeInCurrentUrl($uri) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); @@ -425,50 +570,13 @@ trait AcceptanceTesterActions * ``` * * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + * @see \Codeception\Module\WebDriver::seeInCurrentUrl() */ public function seeInCurrentUrl($uri) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); } - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Checks that the current URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - 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 URI doesn't contain the given string. - * - * ``` php - * dontSeeInCurrentUrl('/users/'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() - */ - public function dontSeeInCurrentUrl($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); - } - - /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -484,7 +592,7 @@ trait AcceptanceTesterActions * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals() */ public function canSeeCurrentUrlEquals($uri) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); @@ -503,13 +611,89 @@ trait AcceptanceTesterActions * ``` * * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals() */ 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 URL matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches() + */ + 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 matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Module\WebDriver::seeCurrentUrlMatches() + */ + public function seeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl() + */ + 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 URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Module\WebDriver::dontSeeInCurrentUrl() + */ + public function dontSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); + } + + /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -525,7 +709,7 @@ trait AcceptanceTesterActions * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals() */ public function cantSeeCurrentUrlEquals($uri) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); @@ -544,52 +728,13 @@ trait AcceptanceTesterActions * ``` * * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals() */ 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 matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - 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 matches the given regular expression. - * - * ``` php - * seeCurrentUrlMatches('~$/users/(\d+)~'); - * ?> - * ``` - * - * @param $uri - * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() - */ - public function seeCurrentUrlMatches($uri) { - return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); - } - - /** * [!] Method is generated. Documentation taken from corresponding module. * @@ -604,7 +749,7 @@ trait AcceptanceTesterActions * * @param $uri * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() */ public function cantSeeCurrentUrlMatches($uri) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); @@ -622,7 +767,7 @@ trait AcceptanceTesterActions * ``` * * @param $uri - * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() */ public function dontSeeCurrentUrlMatches($uri) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); @@ -646,7 +791,7 @@ trait AcceptanceTesterActions * * @internal param $url * @return mixed - * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() + * @see \Codeception\Module\WebDriver::grabFromCurrentUrl() */ public function grabFromCurrentUrl($uri = null) { return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); @@ -668,7 +813,7 @@ trait AcceptanceTesterActions * * @param $checkbox * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() */ public function canSeeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); @@ -687,7 +832,7 @@ trait AcceptanceTesterActions * ``` * * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() */ public function seeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); @@ -708,7 +853,7 @@ trait AcceptanceTesterActions * * @param $checkbox * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() */ public function cantSeeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); @@ -726,7 +871,7 @@ trait AcceptanceTesterActions * ``` * * @param $checkbox - * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() */ public function dontSeeCheckboxIsChecked($checkbox) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); @@ -753,7 +898,7 @@ trait AcceptanceTesterActions * @param $field * @param $value * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInField() + * @see \Codeception\Module\WebDriver::seeInField() */ public function canSeeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); @@ -777,7 +922,7 @@ trait AcceptanceTesterActions * * @param $field * @param $value - * @see \Codeception\Lib\InnerBrowser::seeInField() + * @see \Codeception\Module\WebDriver::seeInField() */ public function seeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); @@ -804,7 +949,7 @@ trait AcceptanceTesterActions * @param $field * @param $value * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + * @see \Codeception\Module\WebDriver::dontSeeInField() */ public function cantSeeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); @@ -828,7 +973,7 @@ trait AcceptanceTesterActions * * @param $field * @param $value - * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + * @see \Codeception\Module\WebDriver::dontSeeInField() */ public function dontSeeInField($field, $value) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); @@ -898,7 +1043,7 @@ trait AcceptanceTesterActions * @param $formSelector * @param $params * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + * @see \Codeception\Module\WebDriver::seeInFormFields() */ public function canSeeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); @@ -965,7 +1110,7 @@ trait AcceptanceTesterActions * * @param $formSelector * @param $params - * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + * @see \Codeception\Module\WebDriver::seeInFormFields() */ public function seeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); @@ -1015,7 +1160,7 @@ trait AcceptanceTesterActions * @param $formSelector * @param $params * Conditional Assertion: Test won't be stopped on fail - * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + * @see \Codeception\Module\WebDriver::dontSeeInFormFields() */ public function cantSeeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); @@ -1062,18 +1207,694 @@ trait AcceptanceTesterActions * * @param $formSelector * @param $params - * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + * @see \Codeception\Module\WebDriver::dontSeeInFormFields() */ public function dontSeeInFormFields($formSelector, $params) { return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', 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')); + * ?> + * ``` + * + * @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. + * + * + * @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. + * + * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. + * + * ``` php + * checkOption('#agree'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Module\WebDriver::checkOption() + */ + 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\Module\WebDriver::uncheckOption() + */ + public function uncheckOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Fills a text field or textarea with the given string. + * + * ``` php + * fillField("//input[@type='text']", "Hello World!"); + * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Module\WebDriver::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. + * + * Attaches a file relative to the Codeception data directory to the given file upload field. + * + * ``` php + * attachFile('input[@type="file"]', 'prices.xls'); + * ?> + * ``` + * + * @param $field + * @param $filename + * @see \Codeception\Module\WebDriver::attachFile() + */ + public function attachFile($field, $filename) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs all visible text from the current page. + * + * @return string + * @see \Codeception\Module\WebDriver::getVisibleText() + */ + public function getVisibleText() { + return $this->getScenario()->runStep(new \Codeception\Step\Action('getVisibleText', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Finds and returns the text contents of the given element. + * If a fuzzy locator is used, the element is found using CSS, XPath, and by matching the full page source by regular expression. + * + * ``` php + * grabTextFrom('h1'); + * $heading = $I->grabTextFrom('descendant-or-self::h1'); + * $value = $I->grabTextFrom('~ + * ``` + * + * @param $cssOrXPathOrRegex + * + * @return mixed + * @see \Codeception\Module\WebDriver::grabTextFrom() + */ + public function grabTextFrom($cssOrXPathOrRegex) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs the value of the given attribute value from the given element. + * Fails if element is not found. + * + * ``` php + * grabAttributeFrom('#tooltip', 'title'); + * ?> + * ``` + * + * + * @param $cssOrXpath + * @param $attribute + * @internal param $element + * @return mixed + * @see \Codeception\Module\WebDriver::grabAttributeFrom() + */ + public function grabAttributeFrom($cssOrXpath, $attribute) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); + } + + + /** + * [!] 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. + * + * + * @see \Codeception\Module\WebDriver::grabMultiple() + */ + public function grabMultiple($cssOrXpath, $attribute = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', 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. + * + * ``` 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 $selector + * @param array $attributes + * @return + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeElement() + */ + 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. + * + * 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 $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. + * + * 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 + * + * @return mixed + * @see \Codeception\Module\WebDriver::seeOptionIsSelected() + */ + public function seeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', 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'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Module\WebDriver::dontSeeOptionIsSelected() + */ + public function dontSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeInTitle() + */ + public function canSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @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 + * + * @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() + */ + 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())); + } + + /** * [!] 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. + * 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. @@ -1126,11 +1947,9 @@ trait AcceptanceTesterActions * $I->submitForm( * '#userForm', * [ - * 'user' => [ - * 'login' => 'Davert', - * 'password' => '123456', - * 'agree' => true - * ] + * 'user[login]' => 'Davert', + * 'user[password]' => '123456', + * 'user[agree]' => true * ], * 'submitButton' * ); @@ -1138,22 +1957,9 @@ trait AcceptanceTesterActions * 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 - * ] - * ] - * ); - * ``` + * 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. * @@ -1171,7 +1977,7 @@ trait AcceptanceTesterActions * ?> * ``` * - * Parameter values can be set to arrays for multiple input fields + * 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. @@ -1222,11 +2028,10 @@ trait AcceptanceTesterActions * ] * ]); * ``` - * * @param $selector * @param $params * @param $button - * @see \Codeception\Lib\InnerBrowser::submitForm() + * @see \Codeception\Module\WebDriver::submitForm() */ public function submitForm($selector, $params, $button = null) { return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); @@ -1236,737 +2041,473 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Fills a text field or textarea with the given string. + * 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. * * ``` php * fillField("//input[@type='text']", "Hello World!"); - * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * use \Facebook\WebDriver\WebDriverElement + * $I->waitForElementChange('#menu', function(WebDriverElement $el) { + * return $el->isDisplayed(); + * }, 100); * ?> * ``` * - * @param $field - * @param $value - * @see \Codeception\Lib\InnerBrowser::fillField() + * @param $element + * @param \Closure $callback + * @param int $timeout seconds + * @throws \Codeception\Exception\ElementNotFound + * @see \Codeception\Module\WebDriver::waitForElementChange() */ - public function fillField($field, $value) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); + public function waitForElementChange($element, $callback, $timeout = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementChange', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Selects an option in a select tag or in radio button group. + * Waits up to $timeout seconds for an element to appear on the page. + * If the element doesn't appear, a timeout exception is thrown. * * ``` php * selectOption('form select[name=account]', 'Premium'); - * $I->selectOption('form input[name=payment]', 'Monthly'); - * $I->selectOption('//form/select[@name=account]', 'Monthly'); + * $I->waitForElement('#agree_button', 30); // secs + * $I->click('#agree_button'); * ?> * ``` * - * Provide an array for the second argument to select multiple options: - * - * ``` php - * selectOption('Which OS do you use?', array('Windows','Linux')); - * ?> - * ``` - * - * @param $select - * @param $option - * @see \Codeception\Lib\InnerBrowser::selectOption() + * @param $element + * @param int $timeout seconds + * @throws \Exception + * @see \Codeception\Module\WebDriver::waitForElement() */ - public function selectOption($select, $option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); + public function waitForElement($element, $timeout = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElement', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. + * 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. * * ``` php * checkOption('#agree'); + * $I->waitForElementVisible('#agree_button', 30); // secs + * $I->click('#agree_button'); * ?> * ``` * - * @param $option - * @see \Codeception\Lib\InnerBrowser::checkOption() + * @param $element + * @param int $timeout seconds + * @throws \Exception + * @see \Codeception\Module\WebDriver::waitForElementVisible() */ - public function checkOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); + public function waitForElementVisible($element, $timeout = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementVisible', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Unticks a checkbox. + * Waits up to $timeout seconds for the given element to become invisible. + * If element stays visible, a timeout exception is thrown. * * ``` php * uncheckOption('#notify'); + * $I->waitForElementNotVisible('#agree_button', 30); // secs * ?> * ``` * - * @param $option - * @see \Codeception\Lib\InnerBrowser::uncheckOption() + * @param $element + * @param int $timeout seconds + * @throws \Exception + * @see \Codeception\Module\WebDriver::waitForElementNotVisible() */ - public function uncheckOption($option) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); + public function waitForElementNotVisible($element, $timeout = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('waitForElementNotVisible', func_get_args())); } /** * [!] Method is generated. Documentation taken from corresponding module. * - * Attaches a file relative to the Codeception data directory to the given file upload field. + * 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. * * ``` php * attachFile('input[@type="file"]', 'prices.xls'); + * $I->waitForText('foo', 30); // secs + * $I->waitForText('foo', 30, '.title'); // secs * ?> * ``` * - * @param $field - * @param $filename - * @see \Codeception\Lib\InnerBrowser::attachFile() + * @param string $text + * @param int $timeout seconds + * @param null $selector + * @throws \Exception + * @see \Codeception\Module\WebDriver::waitForText() */ - public function attachFile($field, $filename) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); + 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. * - * If your page triggers an ajax request, you can perform it manually. - * This action sends a GET ajax request with specified params. + * Wait for $timeout seconds. * - * See ->sendAjaxPostRequest for examples. - * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() + * @param int $timeout secs + * @throws \Codeception\Exception\TestRuntimeException + * @see \Codeception\Module\WebDriver::wait() */ - public function sendAjaxGetRequest($uri, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); + public function wait($timeout) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('wait', 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. + * Low-level API method. + * If Codeception commands are not enough, this allows you to use Selenium WebDriver methods directly: + * + * ``` php + * $I->executeInSelenium(function(\Facebook\WebDriver\RemoteWebDriver $webdriver) { + * $webdriver->get('http://google.com'); + * }); + * ``` + * + * 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() + */ + public function executeInSelenium($function) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInSelenium', 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: - * - * Imagine that by clicking checkbox you trigger ajax request which updates user settings. - * We emulate that click by running this ajax request manually. + * ``` html + * + * ``` * * ``` php * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST - * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET - * + * $I->click("Open window"); + * # switch to another window + * $I->switchToWindow("another_window"); + * # switch to parent window + * $I->switchToWindow(); + * ?> * ``` * - * @param $uri - * @param $params - * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() + * If the window has no name, the only way to access it is via the `executeInSelenium()` method, like so: + * + * ``` php + * executeInSelenium(function (\Facebook\WebDriver\RemoteWebDriver $webdriver) { + * $handles=$webdriver->getWindowHandles(); + * $last_window = end($handles); + * $webdriver->switchTo()->window($last_window); + * }); + * ?> + * ``` + * + * @param string|null $name + * @see \Codeception\Module\WebDriver::switchToWindow() */ - public function sendAjaxPostRequest($uri, $params = null) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); + public function switchToWindow($name = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToWindow', 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. + * Switch to another frame on the page. * * Example: - * - * You need to perform an ajax request specifying the HTTP method. - * - * ``` php - * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); + * ``` html + *