From ac1fe194b98d932f704f49668c3152766c031d38 Mon Sep 17 00:00:00 2001 From: buddha87 Date: Mon, 31 Oct 2016 23:39:56 +0100 Subject: [PATCH] Stream Fixes + Tests --- js/humhub/humhub.client.js | 230 +- js/humhub/humhub.ui.status.js | 6 +- js/humhub/humhub.util.js | 14 + protected/humhub/assets/CoreApiAsset.php | 4 +- .../activity/assets/js/humhub.activity.js | 12 +- .../activity/widgets/views/activityStream.php | 1 + .../modules/comment/tests/codeception.yml | 24 + .../comment/tests/codeception/_bootstrap.php | 57 + .../tests/codeception/_output/.gitignore | 4 + .../codeception/_support/AcceptanceTester.php | 26 + .../codeception/_support/FunctionalTester.php | 26 + .../tests/codeception/_support/UnitTester.php | 26 + .../_generated/AcceptanceTesterActions.php | 2749 +++++++++++++++++ .../_generated/FunctionalTesterActions.php | 2635 ++++++++++++++++ .../_support/_generated/UnitTesterActions.php | 38 + .../tests/codeception/acceptance.suite.yml | 22 + .../codeception/acceptance/_bootstrap.php | 6 + .../tests/codeception/config/functional.php | 3 + .../comment/tests/codeception/config/unit.php | 3 + .../codeception/fixtures/CommentFixture.php | 19 + .../codeception/fixtures/data/comment.php | 9 + .../tests/codeception/functional.suite.yml | 18 + .../codeception/functional/_bootstrap.php | 6 + .../comment/tests/codeception/unit.suite.yml | 9 + .../tests/codeception/unit/_bootstrap.php | 6 + .../modules/comment/tests/config/common.php | 5 + .../comment/tests/config/env/.gitignore | 4 + .../comment/tests/config/functional.php | 5 + .../modules/comment/tests/config/test.php | 11 + .../modules/comment/tests/config/unit.php | 5 + .../codeception/fixtures/ContentFixture.php | 3 +- .../humhub/modules/post/views/post/edit.php | 2 +- .../modules/stream/assets/js/humhub.stream.js | 59 +- .../tests/codeception/_output/.gitignore | 4 + .../codeception/acceptance/StreamCest.php | 110 +- .../modules/stream/widgets/views/stream.php | 4 +- .../codeception/_support/AcceptanceTester.php | 22 +- 37 files changed, 6023 insertions(+), 164 deletions(-) create mode 100644 protected/humhub/modules/comment/tests/codeception.yml create mode 100644 protected/humhub/modules/comment/tests/codeception/_bootstrap.php create mode 100644 protected/humhub/modules/comment/tests/codeception/_output/.gitignore create mode 100644 protected/humhub/modules/comment/tests/codeception/_support/AcceptanceTester.php create mode 100644 protected/humhub/modules/comment/tests/codeception/_support/FunctionalTester.php create mode 100644 protected/humhub/modules/comment/tests/codeception/_support/UnitTester.php create mode 100644 protected/humhub/modules/comment/tests/codeception/_support/_generated/AcceptanceTesterActions.php create mode 100644 protected/humhub/modules/comment/tests/codeception/_support/_generated/FunctionalTesterActions.php create mode 100644 protected/humhub/modules/comment/tests/codeception/_support/_generated/UnitTesterActions.php create mode 100644 protected/humhub/modules/comment/tests/codeception/acceptance.suite.yml create mode 100644 protected/humhub/modules/comment/tests/codeception/acceptance/_bootstrap.php create mode 100644 protected/humhub/modules/comment/tests/codeception/config/functional.php create mode 100644 protected/humhub/modules/comment/tests/codeception/config/unit.php create mode 100644 protected/humhub/modules/comment/tests/codeception/fixtures/CommentFixture.php create mode 100644 protected/humhub/modules/comment/tests/codeception/fixtures/data/comment.php create mode 100644 protected/humhub/modules/comment/tests/codeception/functional.suite.yml create mode 100644 protected/humhub/modules/comment/tests/codeception/functional/_bootstrap.php create mode 100644 protected/humhub/modules/comment/tests/codeception/unit.suite.yml create mode 100644 protected/humhub/modules/comment/tests/codeception/unit/_bootstrap.php create mode 100644 protected/humhub/modules/comment/tests/config/common.php create mode 100644 protected/humhub/modules/comment/tests/config/env/.gitignore create mode 100644 protected/humhub/modules/comment/tests/config/functional.php create mode 100644 protected/humhub/modules/comment/tests/config/test.php create mode 100644 protected/humhub/modules/comment/tests/config/unit.php create mode 100644 protected/humhub/modules/stream/tests/codeception/_output/.gitignore diff --git a/js/humhub/humhub.client.js b/js/humhub/humhub.client.js index 33f609d63b..1a79ef7531 100644 --- a/js/humhub/humhub.client.js +++ b/js/humhub/humhub.client.js @@ -9,159 +9,140 @@ humhub.initModule('client', function (module, require, $) { /** * Response Wrapper Object for easily accessing common data */ - var Response = function (data, dataType) { - if(!dataType || dataType === 'json') { - $.extend(this, data); - } else if(dataType) { - this[dataType] = data; - } else { - this.data = data; - } - }; - - /** - * Checks if the response is a confirmation of the request - * @returns {Boolean} - */ - Response.prototype.isConfirmation = function () { - return this.getStatus() === 0; - }; - - //TODO: isValidationError status 2 - - /** - * Checks if the response is marke - * @returns {humhub.client_L5.Response.data.status|Boolean} - */ - Response.prototype.isError = function () { - return this.getStatus() > 0 || this.getErrors().length; - }; - - Response.prototype.getStatus = function () { - return (this.status) ? this.status : -1; - }; - - Response.prototype.getFirstError = function () { - var errors = this.getErrors(); - if (errors.length) { - return errors[0]; - } - }; - - Response.prototype.setAjaxError = function (xhr, errorThrown, textStatus, data, status) { - this.xhr = xhr; + var Response = function (xhr, url, textStatus, dataType) { + this.url = url; + this.status = xhr.status; + this.response = xhr.responseJSON || xhr.responseText; + //Textstatus = "timeout", "error", "abort", "parsererror", "application" this.textStatus = textStatus; - this.status = status || xhr.status; - this.errors = [errorThrown]; + this.dataType = dataType; + + if (!dataType || dataType === 'json') { + $.extend(this, this.response); + } else if (dataType) { + this[dataType] = this.response; + } }; - /** - * Returns an array of errors or an empty array so getErrors().length is always - * safe. - * @returns {array} error array or empty array - */ - Response.prototype.getErrors = function () { - var errors = this.errors || []; - return (object.isString(errors)) ? [errors] : errors; + Response.prototype.setSuccess = function (data) { + this.data = data; + return this; }; - Response.prototype.toString = function () { - return "{ status: " + this.getStatus() + " error: " + this.getErrors() + " textStatus: " + this.textStatus + " }"; + Response.prototype.setError = function (errorThrown) { + this.error = errorThrown; + this.validationError = (this.status === 400); + return this; + }; + + Response.prototype.isError = function () { + return this.status >= 400; + }; + + Response.prototype.getLog = function () { + var result = $.extend({}, this); + + if(this.response && object.isString(this.response)) { + result.response = this.response.substr(0,200) + result.response += (this.response.length > 200) ? '...' : ''; + }; + + if(this.html && object.isString(this.html)) { + result.html = this.html.substr(0,200) + result.html += (this.html.length > 200) ? '...' : ''; + }; + + return result; }; var submit = function ($form, cfg, originalEvent) { - if($form instanceof $.Event && $form.$form) { + if ($form instanceof $.Event && $form.$form) { originalEvent = $form; $form = $form.$form; - } else if(cfg instanceof $.Event) { + } else if (cfg instanceof $.Event) { originalEvent = cfg; cfg = {}; } - + cfg = cfg || {}; $form = object.isString($form) ? $($form) : $form; cfg.type = $form.attr('method') || 'post'; cfg.data = $form.serialize(); - var url = cfg.url|| $form.attr('action'); + var url = cfg.url || $form.attr('action'); return ajax(url, cfg, originalEvent); }; - var post = function (path, cfg, originalEvent) { - if(path instanceof $.Event) { - originalEvent = path; - path = originalEvent.url; - } else if(cfg instanceof $.Event) { + var post = function (url, cfg, originalEvent) { + if (url instanceof $.Event) { + originalEvent = url; + url = originalEvent.url; + } else if (cfg instanceof $.Event) { originalEvent = cfg; cfg = {}; } - + cfg = cfg || {}; cfg.type = cfg.method = 'POST'; - return ajax(path, cfg, originalEvent); - }; - - var get = function (path, cfg, originalEvent) { - if(path instanceof $.Event) { - originalEvent = path; - path = originalEvent.url; - } else if(cfg instanceof $.Event) { - originalEvent = cfg; - cfg = {}; - } - - cfg = cfg || {}; - cfg.type = cfg.method = 'GET'; - return ajax(path, cfg, originalEvent); + return ajax(url, cfg, originalEvent); }; - var ajax = function (path, cfg, originalEvent) { - - // support for ajax(path, event) and ajax(path, successhandler); - if(cfg instanceof $.Event) { + var get = function (url, cfg, originalEvent) { + if (url instanceof $.Event) { + originalEvent = url; + url = originalEvent.url; + } else if (cfg instanceof $.Event) { originalEvent = cfg; cfg = {}; - } else if(object.isFunction(cfg)) { - cfg = {'success' : cfg}; } + + cfg = cfg || {}; + cfg.type = cfg.method = 'GET'; + return ajax(url, cfg, originalEvent); + }; + + var ajax = function (url, cfg, originalEvent) { + + // support for ajax(url, event) and ajax(path, successhandler); + if (cfg instanceof $.Event) { + originalEvent = cfg; + cfg = {}; + } else if (object.isFunction(cfg)) { + cfg = {'success': cfg}; + } + var promise = new Promise(function (resolve, reject) { cfg = cfg || {}; - - //Wrap the actual error handler with our own and call + var errorHandler = cfg.error; - var error = function (xhr, textStatus, errorThrown, data) { - //Textstatus = "timeout", "error", "abort", "parsererror", "application" + var error = function (xhr, textStatus, errorThrown) { + var response = new Response(xhr, url, textStatus, cfg.dataType).setError(errorThrown); + if (errorHandler && object.isFunction(errorHandler)) { - var response = new Response(); - response.setAjaxError(xhr, errorThrown, textStatus, data, xhr.status); errorHandler(response); } - + finish(originalEvent); - reject({'url' : path, 'textStatus': textStatus, 'response': xhr.responseJSON, 'error': errorThrown, 'data': data, 'status': xhr.status}); + reject(response); }; var successHandler = cfg.success; var success = function (data, textStatus, xhr) { - var response = new Response(data, cfg.dataType); - if (response.isError()) { //Application errors - return error(xhr, "application", response.getErrors(), data, response.getStatus()); - } else if (successHandler) { - response.textStatus = textStatus; - response.xhr = xhr; + var response = new Response(xhr, url, textStatus, cfg.dataType).setSuccess(data); + if (successHandler) { successHandler(response); } - + finish(originalEvent); resolve(response); - + // Other modules can register global handler by the response type given by the backend. // For example {type:'modal', 'content': '...') - if(response.type) { - event.trigger('humhub:modules:client:response:'+response.type); + if (response.type) { + event.trigger('humhub:modules:client:response:' + response.type); } - - promise.done(function() { + + promise.done(function () { // If content with tags are inserted in resolve, the ajaxComplete handler in yii.js // makes sure redundant stylesheets are removed. Here we get sure it is called after inserting the response. $(document).trigger('ajaxComplete'); @@ -171,28 +152,55 @@ humhub.initModule('client', function (module, require, $) { //Overwriting the handler with our wrapper handler cfg.success = success; cfg.error = error; - cfg.url = path; + cfg.url = url; //Setting some default values cfg.dataType = cfg.dataType || "json"; $.ajax(cfg); }); - + + promise.status = function (setting) { + return new Promise(function (resolve, reject) { + promise.then(function (response) { + try { + if (setting[response.status]) { + setting[response.status](response); + } + resolve(response); + } catch (e) { + reject(e); + } + }).catch(function (response) { + try { + if (setting[response.status]) { + setting[response.status](response); + resolve(response); + } else { + reject(response); + } + } catch (e) { + reject(e); + } + }); + }); + }; + return promise; }; - - var finish = function(originalEvent) { - if(originalEvent && object.isFunction(originalEvent.finish)) { + + var finish = function (originalEvent) { + if (originalEvent && object.isFunction(originalEvent.finish)) { originalEvent.finish(); } }; - + module.export({ ajax: ajax, post: post, get: get, - submit: submit + submit: submit, + Response: Response }); }); diff --git a/js/humhub/humhub.ui.status.js b/js/humhub/humhub.ui.status.js index 9d9356e311..7040b65b35 100644 --- a/js/humhub/humhub.ui.status.js +++ b/js/humhub/humhub.ui.status.js @@ -8,6 +8,7 @@ humhub.initModule('ui.status', function (module, require, $) { var event = require('event'); var log = require('log'); var object = require('util').object; + var client = require('client'); var SELECTOR_ROOT = '#status-bar'; var SELECTOR_BODY = '.status-bar-body'; @@ -113,9 +114,12 @@ humhub.initModule('ui.status', function (module, require, $) { if (error.error instanceof Error) { error.stack = (error.error.stack) ? error.error.stack : undefined; error.error = error.error.message; + } else if(error instanceof client.Response) { + error = error.getLog(); } try { - return JSON.stringify(error, null, 4); + // encode + return $('
').text(JSON.stringify(error, null, 4)).html(); } catch(e) { return error.toString(); } diff --git a/js/humhub/humhub.util.js b/js/humhub/humhub.util.js index 7fc5f337c3..4757fcda7c 100644 --- a/js/humhub/humhub.util.js +++ b/js/humhub/humhub.util.js @@ -44,6 +44,20 @@ humhub.initModule('util', function(module, require, $) { inherits: function(Sub, Parent) { Sub.prototype = Object.create(Parent.prototype); Sub._super = Parent.prototype; + Sub.prototype.super = function(method) { + if(!Sub._super[arguments[0]]) { + throw new Error('Call of undefined method of super type'); + } + + var args; + + if(arguments.length > 1){ + args = []; + Array.prototype.push.apply( args, arguments ); + args.shift(); + } + return Sub._super[arguments[0]].apply(this, args); + }; } }; diff --git a/protected/humhub/assets/CoreApiAsset.php b/protected/humhub/assets/CoreApiAsset.php index d1920007e3..3e028553d3 100755 --- a/protected/humhub/assets/CoreApiAsset.php +++ b/protected/humhub/assets/CoreApiAsset.php @@ -47,13 +47,13 @@ class CoreApiAsset extends AssetBundle 'js/humhub/humhub.util.js', 'js/humhub/humhub.log.js', //'js/humhub/humhub.scripts.js', - 'js/humhub/humhub.ui.status.js', 'js/humhub/humhub.ui.additions.js', 'js/humhub/humhub.ui.loader.js', 'js/humhub/humhub.ui.modal.js', 'js/humhub/humhub.client.js', 'js/humhub/humhub.client.pjax.js', - 'js/humhub/humhub.action.js' + 'js/humhub/humhub.action.js', + 'js/humhub/humhub.ui.status.js' ]; /** diff --git a/protected/humhub/modules/activity/assets/js/humhub.activity.js b/protected/humhub/modules/activity/assets/js/humhub.activity.js index 5fb807cdff..cf8c564741 100644 --- a/protected/humhub/modules/activity/assets/js/humhub.activity.js +++ b/protected/humhub/modules/activity/assets/js/humhub.activity.js @@ -85,7 +85,7 @@ humhub.initModule('activity', function (module, require, $) { var stream = getStream(); if (!stream) { - console.log('No activity stream found!'); + module.log.info('No activity stream found!'); return; } @@ -96,16 +96,16 @@ humhub.initModule('activity', function (module, require, $) { // listen for scrolling event yes or no var scrolling = true; - stream.$content.scroll(function () { - + stream.$content.scroll(function (evt) { + // save height of the overflow container - var _containerHeight = $("#activityContents").height(); + var _containerHeight = stream.$content.height(); // save scroll height - var _scrollHeight = $("#activityContents").prop("scrollHeight"); + var _scrollHeight = stream.$content.prop("scrollHeight"); // save current scrollbar position - var _currentScrollPosition = $('#activityContents').scrollTop(); + var _currentScrollPosition = stream.$content.scrollTop(); // load more activites if current scroll position is near scroll height if (_currentScrollPosition >= (_scrollHeight - _containerHeight - 30)) { diff --git a/protected/humhub/modules/activity/widgets/views/activityStream.php b/protected/humhub/modules/activity/widgets/views/activityStream.php index 884702654f..8f83ef47ef 100644 --- a/protected/humhub/modules/activity/widgets/views/activityStream.php +++ b/protected/humhub/modules/activity/widgets/views/activityStream.php @@ -31,6 +31,7 @@ $this->registerJsVar('activityInfoUrl', $infoUrl); cursorborder: "", cursorcolor: "#555", cursoropacitymax: "0.2", + nativeparentscrolling: false, railpadding: {top: 0, right: 3, left: 0, bottom: 0} }); diff --git a/protected/humhub/modules/comment/tests/codeception.yml b/protected/humhub/modules/comment/tests/codeception.yml new file mode 100644 index 0000000000..f9d1a2ec6c --- /dev/null +++ b/protected/humhub/modules/comment/tests/codeception.yml @@ -0,0 +1,24 @@ +actor: Tester +namespace: comment +settings: + bootstrap: _bootstrap.php + suite_class: \PHPUnit_Framework_TestSuite + colors: true + shuffle: false + memory_limit: 1024M + log: true + + # This value controls whether PHPUnit attempts to backup global variables + # See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals + backup_globals: true +paths: + tests: codeception + log: codeception/_output + data: codeception/_data + helpers: codeception/_support + envs: config/env +config: + # the entry script URL (with host info) for functional and acceptance tests + # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL + test_entry_url: http://localhost:8080/index-test.php + \ No newline at end of file diff --git a/protected/humhub/modules/comment/tests/codeception/_bootstrap.php b/protected/humhub/modules/comment/tests/codeception/_bootstrap.php new file mode 100644 index 0000000000..775f914c17 --- /dev/null +++ b/protected/humhub/modules/comment/tests/codeception/_bootstrap.php @@ -0,0 +1,57 @@ + 0) { + \Codeception\Configuration::append(['environment' => $env]); + + echo 'Run execution environment: ' . $env[0][0] . PHP_EOL; + + $envCfgFile = dirname(__DIR__) . '/config/env/test.' . $env[0][0] . '.php'; + + if (file_exists($envCfgFile)) { + $cfg = array_merge(require_once(__DIR__ . '/../config/test.php'), require_once($envCfgFile)); + } +} + +// If no environment is set we have to load the default config +if (!isset($cfg)) { + $cfg = require_once(__DIR__ . '/../config/test.php'); +} + +// If no humhub_root is given we assume our module is in the a root to be in /protected/humhub/modules//tests/codeception directory +$cfg['humhub_root'] = isset($cfg['humhub_root']) ? $cfg['humhub_root'] : dirname(__DIR__) . '/../../../../..'; + +echo 'Using HumHub Root: ' . $cfg['humhub_root'] . PHP_EOL; + +// Load default test bootstrap +require_once($cfg['humhub_root'] . '/protected/humhub/tests/codeception/_bootstrap.php'); + +// Overwrite the default test alias +Yii::setAlias('@tests', dirname(__DIR__)); +Yii::setAlias('@env', '@tests/config/env'); +Yii::setAlias('@root', $cfg['humhub_root']); +Yii::setAlias('@humhubTests', $cfg['humhub_root'] . '/protected/humhub/tests'); + +// Load all supporting test classes needed for test execution +\Codeception\Util\Autoload::addNamespace('', Yii::getAlias('@humhubTests/codeception/_support')); +\Codeception\Util\Autoload::addNamespace('tests\codeception\fixtures', Yii::getAlias('@humhubTests/codeception/fixtures')); +\Codeception\Util\Autoload::addNamespace('', Yii::getAlias('@humhubTests/codeception/_pages')); +if(isset($cfg['modules'])) { + \Codeception\Configuration::append(['humhub_modules' => $cfg['modules']]); +} + +if(isset($cfg['fixtures'])) { + \Codeception\Configuration::append(['fixtures' => $cfg['fixtures']]); +} +?> \ No newline at end of file diff --git a/protected/humhub/modules/comment/tests/codeception/_output/.gitignore b/protected/humhub/modules/comment/tests/codeception/_output/.gitignore new file mode 100644 index 0000000000..86d0cb2726 --- /dev/null +++ b/protected/humhub/modules/comment/tests/codeception/_output/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/protected/humhub/modules/comment/tests/codeception/_support/AcceptanceTester.php b/protected/humhub/modules/comment/tests/codeception/_support/AcceptanceTester.php new file mode 100644 index 0000000000..2b093390f9 --- /dev/null +++ b/protected/humhub/modules/comment/tests/codeception/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ +getScenario()->runStep(new \Codeception\Step\Action('debugWebDriverLogs', 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 + * + * @return mixed + * @see \Codeception\Module\WebDriver::amOnSubdomain() + */ + public function amOnSubdomain($subdomain) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', 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`. + * + * ``` php + * amOnPage('/user/edit'); + * $I->makeScreenshot('edit_page'); + * // saved to: tests/_output/debug/edit_page.png + * ?> + * ``` + * + * @param $name + * @see \Codeception\Module\WebDriver::makeScreenshot() + */ + 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`, `expires`, `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())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens the page for the given relative URI. + * + * ``` php + * amOnPage('/'); + * // opens /register page + * $I->amOnPage('/register'); + * ``` + * + * @param $page + * @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 (case insensitive). + * + * You can specify a specific HTML element (via CSS or XPath) as the second + * parameter to only search within that element. + * + * ``` 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 + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->see('strong')` will return true for strings like: + * + * - `

I am Stronger than thou

` + * - `` + * + * But will *not* be true for strings like: + * + * - `Home` + * - `
Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @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 (case insensitive). + * + * You can specify a specific HTML element (via CSS or XPath) as the second + * parameter to only search within that element. + * + * ``` 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 + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->see('strong')` will return true for strings like: + * + * - `

I am Stronger than thou

` + * - `` + * + * But will *not* be true for strings like: + * + * - `Home` + * - `
Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @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 (case insensitive). + * 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 + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->dontSee('strong')` will fail on strings like: + * + * - `

I am Stronger than thou

` + * - `` + * + * But will ignore strings like: + * + * - `Home` + * - `
Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @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 (case insensitive). + * 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 + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->dontSee('strong')` will fail on strings like: + * + * - `

I am Stronger than thou

` + * - `` + * + * But will ignore strings like: + * + * - `Home` + * - `
Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @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 current page contains the given string in its + * raw source code. + * + * ``` php + * seeInSource('

Green eggs & ham

'); + * ``` + * + * @param $raw + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeInSource() + */ + public function canSeeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string in its + * raw source code. + * + * ``` php + * seeInSource('

Green eggs & ham

'); + * ``` + * + * @param $raw + * @see \Codeception\Module\WebDriver::seeInSource() + */ + public function seeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string in its + * raw source code. + * + * ```php + * dontSeeInSource('

Green eggs & ham

'); + * ``` + * + * @param $raw + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeInSource() + */ + public function cantSeeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string in its + * raw source code. + * + * ```php + * dontSeeInSource('

Green eggs & ham

'); + * ``` + * + * @param $raw + * @see \Codeception\Module\WebDriver::dontSeeInSource() + */ + public function dontSeeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', 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. + * + * 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. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeInCurrentUrl() + */ + public function canSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current URI contains the given string. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @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 URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeCurrentUrlEquals() + */ + 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 is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @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. + * + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlEquals() + */ + 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 URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @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 current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() + */ + public function cantSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Module\WebDriver::dontSeeCurrentUrlMatches() + */ + public function dontSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Executes the given regular expression against the current URI and returns the first match. + * If no parameters are provided, the full URI is returned. + * + * ``` php + * grabFromCurrentUrl('~$/user/(\d+)/~'); + * $uri = $I->grabFromCurrentUrl(); + * ?> + * ``` + * + * @param null $uri + * + * @return mixed + * @see \Codeception\Module\WebDriver::grabFromCurrentUrl() + */ + public function grabFromCurrentUrl($uri = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() + */ + public function canSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Module\WebDriver::seeCheckboxIsChecked() + */ + public function seeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() + */ + public function cantSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Module\WebDriver::dontSeeCheckboxIsChecked() + */ + public function dontSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeInField() + */ + public function canSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Module\WebDriver::seeInField() + */ + public function seeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeInField() + */ + public function cantSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Module\WebDriver::dontSeeInField() + */ + public function dontSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm 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); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::seeInFormFields() + */ + public function canSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm 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); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @see \Codeception\Module\WebDriver::seeInFormFields() + */ + public function seeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\WebDriver::dontSeeInFormFields() + */ + public function cantSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @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 + * + * @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. + * + * Grabs either the text content, or attribute values, of nodes + * matched by $cssOrXpath and returns them as an array. + * + * ```html + * First + * Second + * Third + * ``` + * + * ```php + * grabMultiple('a'); + * + * // would return ['#first', '#second', '#third'] + * $aLinks = $I->grabMultiple('a', 'href'); + * ?> + * ``` + * + * @param $cssOrXpath + * @param $attribute + * @return string[] + * @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. + * + * + * 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 + * + * @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. 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 + * ]); + * ``` + * + * The solution is to pass an array value: + * + * ```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() + */ + 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. + * + * 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 + * waitForElementChange('#menu', function(WebDriverElement $el) { + * return $el->isDisplayed(); + * }, 100); + * ?> + * ``` + * + * @param $element + * @param \Closure $callback + * @param int $timeout seconds + * @throws \Codeception\Exception\ElementNotFound + * @see \Codeception\Module\WebDriver::waitForElementChange() + */ + 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. + * + * 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 + * waitForElement('#agree_button', 30); // secs + * $I->click('#agree_button'); + * ?> + * ``` + * + * @param $element + * @param int $timeout seconds + * @throws \Exception + * @see \Codeception\Module\WebDriver::waitForElement() + */ + 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. + * + * 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 + * waitForElementVisible('#agree_button', 30); // secs + * $I->click('#agree_button'); + * ?> + * ``` + * + * @param $element + * @param int $timeout seconds + * @throws \Exception + * @see \Codeception\Module\WebDriver::waitForElementVisible() + */ + 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. + * + * Waits up to $timeout seconds for the given element to become invisible. + * If element stays visible, a timeout exception is thrown. + * + * ``` php + * waitForElementNotVisible('#agree_button', 30); // secs + * ?> + * ``` + * + * @param $element + * @param int $timeout seconds + * @throws \Exception + * @see \Codeception\Module\WebDriver::waitForElementNotVisible() + */ + 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. + * + * 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 + * waitForText('foo', 30); // secs + * $I->waitForText('foo', 30, '.title'); // secs + * ?> + * ``` + * + * @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() + */ + public function wait($timeout) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('wait', 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: + * + * ``` php + * $I->executeInSelenium(function(\Facebook\WebDriver\Remote\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: + * ``` 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: + * + * ``` php + * executeInSelenium(function (\Facebook\WebDriver\Remote\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 switchToWindow($name = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToWindow', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Switch to another frame on the page. + * + * Example: + * ``` html + *