Complex classes like FunctionalTesterActions often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FunctionalTesterActions, and based on these observations, apply Extract Interface, too.
| 1 | <?php //[STAMP] 1be3e8cabbe74505eea48cf93dbf2209 |
||
| 12 | trait FunctionalTesterActions |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @return \Codeception\Scenario |
||
| 16 | */ |
||
| 17 | abstract protected function getScenario(); |
||
| 18 | |||
| 19 | |||
| 20 | /** |
||
| 21 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 22 | * |
||
| 23 | * Authorizes user on a site without submitting login form. |
||
| 24 | * Use it for fast pragmatic authorization in functional tests. |
||
| 25 | * |
||
| 26 | * ```php |
||
| 27 | * <?php |
||
| 28 | * // User is found by id |
||
| 29 | * $I->amLoggedInAs(1); |
||
| 30 | * |
||
| 31 | * // User object is passed as parameter |
||
| 32 | * $admin = \app\models\User::findByUsername('admin'); |
||
| 33 | * $I->amLoggedInAs($admin); |
||
| 34 | * ``` |
||
| 35 | * Requires `user` component to be enabled and configured. |
||
| 36 | * |
||
| 37 | * @param $user |
||
| 38 | * @throws ModuleException |
||
| 39 | * @see \Codeception\Module\Yii2::amLoggedInAs() |
||
| 40 | */ |
||
| 41 | public function amLoggedInAs($user) { |
||
| 44 | |||
| 45 | |||
| 46 | /** |
||
| 47 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 48 | * |
||
| 49 | * Creates and loads fixtures from a config. |
||
| 50 | * Signature is the same as for `fixtures()` method of `yii\test\FixtureTrait` |
||
| 51 | * |
||
| 52 | * ```php |
||
| 53 | * <?php |
||
| 54 | * $I->haveFixtures([ |
||
| 55 | * 'posts' => PostsFixture::className(), |
||
| 56 | * 'user' => [ |
||
| 57 | * 'class' => UserFixture::className(), |
||
| 58 | * 'dataFile' => '@tests/_data/models/user.php', |
||
| 59 | * ], |
||
| 60 | * ]); |
||
| 61 | * ``` |
||
| 62 | * |
||
| 63 | * Note: if you need to load fixtures before the test (probably before the cleanup transaction is started; |
||
| 64 | * `cleanup` options is `true` by default), you can specify fixtures with _fixtures method of a testcase |
||
| 65 | * ```php |
||
| 66 | * <?php |
||
| 67 | * // inside Cest file or Codeception\TestCase\Unit |
||
| 68 | * public function _fixtures(){ |
||
| 69 | * return [ |
||
| 70 | * 'user' => [ |
||
| 71 | * 'class' => UserFixture::className(), |
||
| 72 | * 'dataFile' => codecept_data_dir() . 'user.php' |
||
| 73 | * ] |
||
| 74 | * ]; |
||
| 75 | * } |
||
| 76 | * ``` |
||
| 77 | * instead of defining `haveFixtures` in Cest `_before` |
||
| 78 | * |
||
| 79 | * @param $fixtures |
||
| 80 | * @part fixtures |
||
| 81 | * @see \Codeception\Module\Yii2::haveFixtures() |
||
| 82 | */ |
||
| 83 | public function haveFixtures($fixtures) { |
||
| 86 | |||
| 87 | |||
| 88 | /** |
||
| 89 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 90 | * |
||
| 91 | * Returns all loaded fixtures. |
||
| 92 | * Array of fixture instances |
||
| 93 | * |
||
| 94 | * @part fixtures |
||
| 95 | * @return array |
||
| 96 | * @see \Codeception\Module\Yii2::grabFixtures() |
||
| 97 | */ |
||
| 98 | public function grabFixtures() { |
||
| 101 | |||
| 102 | |||
| 103 | /** |
||
| 104 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 105 | * |
||
| 106 | * Gets a fixture by name. |
||
| 107 | * Returns a Fixture instance. If a fixture is an instance of `\yii\test\BaseActiveFixture` a second parameter |
||
| 108 | * can be used to return a specific model: |
||
| 109 | * |
||
| 110 | * ```php |
||
| 111 | * <?php |
||
| 112 | * $I->haveFixtures(['users' => UserFixture::className()]); |
||
| 113 | * |
||
| 114 | * $users = $I->grabFixture('users'); |
||
| 115 | * |
||
| 116 | * // get first user by key, if a fixture is instance of ActiveFixture |
||
| 117 | * $user = $I->grabFixture('users', 'user1'); |
||
| 118 | * ``` |
||
| 119 | * |
||
| 120 | * @param $name |
||
| 121 | * @return mixed |
||
| 122 | * @throws ModuleException if a fixture is not found |
||
| 123 | * @part fixtures |
||
| 124 | * @see \Codeception\Module\Yii2::grabFixture() |
||
| 125 | */ |
||
| 126 | public function grabFixture($name, $index = null) { |
||
| 129 | |||
| 130 | |||
| 131 | /** |
||
| 132 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 133 | * |
||
| 134 | * Inserts record into the database. |
||
| 135 | * |
||
| 136 | * ``` php |
||
| 137 | * <?php |
||
| 138 | * $user_id = $I->haveRecord('app\models\User', array('name' => 'Davert')); |
||
| 139 | * ?> |
||
| 140 | * ``` |
||
| 141 | * |
||
| 142 | * @param $model |
||
| 143 | * @param array $attributes |
||
| 144 | * @return mixed |
||
| 145 | * @part orm |
||
| 146 | * @see \Codeception\Module\Yii2::haveRecord() |
||
| 147 | */ |
||
| 148 | public function haveRecord($model, $attributes = null) { |
||
| 149 | return $this->getScenario()->runStep(new \Codeception\Step\Action('haveRecord', func_get_args())); |
||
| 150 | } |
||
| 151 | |||
| 152 | |||
| 153 | /** |
||
| 154 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 155 | * |
||
| 156 | * Checks that record exists in database. |
||
| 157 | * |
||
| 158 | * ``` php |
||
| 159 | * $I->seeRecord('app\models\User', array('name' => 'davert')); |
||
| 160 | * ``` |
||
| 161 | * |
||
| 162 | * @param $model |
||
| 163 | * @param array $attributes |
||
| 164 | * @part orm |
||
| 165 | * Conditional Assertion: Test won't be stopped on fail |
||
| 166 | * @see \Codeception\Module\Yii2::seeRecord() |
||
| 167 | */ |
||
| 168 | public function canSeeRecord($model, $attributes = null) { |
||
| 169 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeRecord', func_get_args())); |
||
| 170 | } |
||
| 171 | /** |
||
| 172 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 173 | * |
||
| 174 | * Checks that record exists in database. |
||
| 175 | * |
||
| 176 | * ``` php |
||
| 177 | * $I->seeRecord('app\models\User', array('name' => 'davert')); |
||
| 178 | * ``` |
||
| 179 | * |
||
| 180 | * @param $model |
||
| 181 | * @param array $attributes |
||
| 182 | * @part orm |
||
| 183 | * @see \Codeception\Module\Yii2::seeRecord() |
||
| 184 | */ |
||
| 185 | public function seeRecord($model, $attributes = null) { |
||
| 186 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeRecord', func_get_args())); |
||
| 187 | } |
||
| 188 | |||
| 189 | |||
| 190 | /** |
||
| 191 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 192 | * |
||
| 193 | * Checks that record does not exist in database. |
||
| 194 | * |
||
| 195 | * ``` php |
||
| 196 | * $I->dontSeeRecord('app\models\User', array('name' => 'davert')); |
||
| 197 | * ``` |
||
| 198 | * |
||
| 199 | * @param $model |
||
| 200 | * @param array $attributes |
||
| 201 | * @part orm |
||
| 202 | * Conditional Assertion: Test won't be stopped on fail |
||
| 203 | * @see \Codeception\Module\Yii2::dontSeeRecord() |
||
| 204 | */ |
||
| 205 | public function cantSeeRecord($model, $attributes = null) { |
||
| 206 | return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeRecord', func_get_args())); |
||
| 207 | } |
||
| 208 | /** |
||
| 209 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 210 | * |
||
| 211 | * Checks that record does not exist in database. |
||
| 212 | * |
||
| 213 | * ``` php |
||
| 214 | * $I->dontSeeRecord('app\models\User', array('name' => 'davert')); |
||
| 215 | * ``` |
||
| 216 | * |
||
| 217 | * @param $model |
||
| 218 | * @param array $attributes |
||
| 219 | * @part orm |
||
| 220 | * @see \Codeception\Module\Yii2::dontSeeRecord() |
||
| 221 | */ |
||
| 222 | public function dontSeeRecord($model, $attributes = null) { |
||
| 223 | return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeRecord', func_get_args())); |
||
| 224 | } |
||
| 225 | |||
| 226 | |||
| 227 | /** |
||
| 228 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 229 | * |
||
| 230 | * Retrieves record from database |
||
| 231 | * |
||
| 232 | * ``` php |
||
| 233 | * $category = $I->grabRecord('app\models\User', array('name' => 'davert')); |
||
| 234 | * ``` |
||
| 235 | * |
||
| 236 | * @param $model |
||
| 237 | * @param array $attributes |
||
| 238 | * @return mixed |
||
| 239 | * @part orm |
||
| 240 | * @see \Codeception\Module\Yii2::grabRecord() |
||
| 241 | */ |
||
| 242 | public function grabRecord($model, $attributes = null) { |
||
| 243 | return $this->getScenario()->runStep(new \Codeception\Step\Action('grabRecord', func_get_args())); |
||
| 244 | } |
||
| 245 | |||
| 246 | |||
| 247 | /** |
||
| 248 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 249 | * |
||
| 250 | * Similar to amOnPage but accepts route as first argument and params as second |
||
| 251 | * |
||
| 252 | * ``` |
||
| 253 | * $I->amOnRoute('site/view', ['page' => 'about']); |
||
| 254 | * ``` |
||
| 255 | * |
||
| 256 | * @see \Codeception\Module\Yii2::amOnRoute() |
||
| 257 | */ |
||
| 258 | public function amOnRoute($route, $params = null) { |
||
| 259 | return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnRoute', func_get_args())); |
||
| 260 | } |
||
| 261 | |||
| 262 | |||
| 263 | /** |
||
| 264 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 265 | * |
||
| 266 | * Gets a component from Yii container. Throws exception if component is not available |
||
| 267 | * |
||
| 268 | * ```php |
||
| 269 | * <?php |
||
| 270 | * $mailer = $I->grabComponent('mailer'); |
||
| 271 | * ``` |
||
| 272 | * |
||
| 273 | * @param $component |
||
| 274 | * @return mixed |
||
| 275 | * @throws ModuleException |
||
| 276 | * @see \Codeception\Module\Yii2::grabComponent() |
||
| 277 | */ |
||
| 278 | public function grabComponent($component) { |
||
| 281 | |||
| 282 | |||
| 283 | /** |
||
| 284 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 285 | * |
||
| 286 | * Checks that email is sent. |
||
| 287 | * |
||
| 288 | * ```php |
||
| 289 | * <?php |
||
| 290 | * // check that at least 1 email was sent |
||
| 291 | * $I->seeEmailIsSent(); |
||
| 292 | * |
||
| 293 | * // check that only 3 emails were sent |
||
| 294 | * $I->seeEmailIsSent(3); |
||
| 295 | * ``` |
||
| 296 | * |
||
| 297 | * @param int $num |
||
| 298 | * @throws ModuleException |
||
| 299 | * @part email |
||
| 300 | * Conditional Assertion: Test won't be stopped on fail |
||
| 301 | * @see \Codeception\Module\Yii2::seeEmailIsSent() |
||
| 302 | */ |
||
| 303 | public function canSeeEmailIsSent($num = null) { |
||
| 306 | /** |
||
| 307 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 308 | * |
||
| 309 | * Checks that email is sent. |
||
| 310 | * |
||
| 311 | * ```php |
||
| 312 | * <?php |
||
| 313 | * // check that at least 1 email was sent |
||
| 314 | * $I->seeEmailIsSent(); |
||
| 315 | * |
||
| 316 | * // check that only 3 emails were sent |
||
| 317 | * $I->seeEmailIsSent(3); |
||
| 318 | * ``` |
||
| 319 | * |
||
| 320 | * @param int $num |
||
| 321 | * @throws ModuleException |
||
| 322 | * @part email |
||
| 323 | * @see \Codeception\Module\Yii2::seeEmailIsSent() |
||
| 324 | */ |
||
| 325 | public function seeEmailIsSent($num = null) { |
||
| 328 | |||
| 329 | |||
| 330 | /** |
||
| 331 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 332 | * |
||
| 333 | * Checks that no email was sent |
||
| 334 | * |
||
| 335 | * @part email |
||
| 336 | * Conditional Assertion: Test won't be stopped on fail |
||
| 337 | * @see \Codeception\Module\Yii2::dontSeeEmailIsSent() |
||
| 338 | */ |
||
| 339 | public function cantSeeEmailIsSent() { |
||
| 342 | /** |
||
| 343 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 344 | * |
||
| 345 | * Checks that no email was sent |
||
| 346 | * |
||
| 347 | * @part email |
||
| 348 | * @see \Codeception\Module\Yii2::dontSeeEmailIsSent() |
||
| 349 | */ |
||
| 350 | public function dontSeeEmailIsSent() { |
||
| 353 | |||
| 354 | |||
| 355 | /** |
||
| 356 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 357 | * |
||
| 358 | * Returns array of all sent email messages. |
||
| 359 | * Each message implements `yii\mail\Message` interface. |
||
| 360 | * Useful to perform additional checks using `Asserts` module: |
||
| 361 | * |
||
| 362 | * ```php |
||
| 363 | * <?php |
||
| 364 | * $I->seeEmailIsSent(); |
||
| 365 | * $messages = $I->grabSentEmails(); |
||
| 366 | * $I->assertEquals('admin@site,com', $messages[0]->getTo()); |
||
| 367 | * ``` |
||
| 368 | * |
||
| 369 | * @part email |
||
| 370 | * @return array |
||
| 371 | * @throws ModuleException |
||
| 372 | * @see \Codeception\Module\Yii2::grabSentEmails() |
||
| 373 | */ |
||
| 374 | public function grabSentEmails() { |
||
| 377 | |||
| 378 | |||
| 379 | /** |
||
| 380 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 381 | * |
||
| 382 | * Returns last sent email: |
||
| 383 | * |
||
| 384 | * ```php |
||
| 385 | * <?php |
||
| 386 | * $I->seeEmailIsSent(); |
||
| 387 | * $message = $I->grabLastSentEmail(); |
||
| 388 | * $I->assertEquals('admin@site,com', $message->getTo()); |
||
| 389 | * ``` |
||
| 390 | * @part email |
||
| 391 | * @see \Codeception\Module\Yii2::grabLastSentEmail() |
||
| 392 | */ |
||
| 393 | public function grabLastSentEmail() { |
||
| 396 | |||
| 397 | |||
| 398 | /** |
||
| 399 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 400 | * |
||
| 401 | * Returns a list of regex patterns for recognized domain names |
||
| 402 | * |
||
| 403 | * @return array |
||
| 404 | * @see \Codeception\Module\Yii2::getInternalDomains() |
||
| 405 | */ |
||
| 406 | public function getInternalDomains() { |
||
| 409 | |||
| 410 | |||
| 411 | /** |
||
| 412 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 413 | * |
||
| 414 | * Authenticates user for HTTP_AUTH |
||
| 415 | * |
||
| 416 | * @param $username |
||
| 417 | * @param $password |
||
| 418 | * @see \Codeception\Lib\InnerBrowser::amHttpAuthenticated() |
||
| 419 | */ |
||
| 420 | public function amHttpAuthenticated($username, $password) { |
||
| 423 | |||
| 424 | |||
| 425 | /** |
||
| 426 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 427 | * |
||
| 428 | * Sets the HTTP header to the passed value - which is used on |
||
| 429 | * subsequent HTTP requests through PhpBrowser. |
||
| 430 | * |
||
| 431 | * Example: |
||
| 432 | * ```php |
||
| 433 | * <?php |
||
| 434 | * $I->setHeader('X-Requested-With', 'Codeception'); |
||
| 435 | * $I->amOnPage('test-headers.php'); |
||
| 436 | * ?> |
||
| 437 | * ``` |
||
| 438 | * |
||
| 439 | * @param string $name the name of the request header |
||
| 440 | * @param string $value the value to set it to for subsequent |
||
| 441 | * requests |
||
| 442 | * @see \Codeception\Lib\InnerBrowser::haveHttpHeader() |
||
| 443 | */ |
||
| 444 | public function haveHttpHeader($name, $value) { |
||
| 447 | |||
| 448 | |||
| 449 | /** |
||
| 450 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 451 | * |
||
| 452 | * Deletes the header with the passed name. Subsequent requests |
||
| 453 | * will not have the deleted header in its request. |
||
| 454 | * |
||
| 455 | * Example: |
||
| 456 | * ```php |
||
| 457 | * <?php |
||
| 458 | * $I->haveHttpHeader('X-Requested-With', 'Codeception'); |
||
| 459 | * $I->amOnPage('test-headers.php'); |
||
| 460 | * // ... |
||
| 461 | * $I->deleteHeader('X-Requested-With'); |
||
| 462 | * $I->amOnPage('some-other-page.php'); |
||
| 463 | * ?> |
||
| 464 | * ``` |
||
| 465 | * |
||
| 466 | * @param string $name the name of the header to delete. |
||
| 467 | * @see \Codeception\Lib\InnerBrowser::deleteHeader() |
||
| 468 | */ |
||
| 469 | public function deleteHeader($name) { |
||
| 472 | |||
| 473 | |||
| 474 | /** |
||
| 475 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 476 | * |
||
| 477 | * Opens the page for the given relative URI. |
||
| 478 | * |
||
| 479 | * ``` php |
||
| 480 | * <?php |
||
| 481 | * // opens front page |
||
| 482 | * $I->amOnPage('/'); |
||
| 483 | * // opens /register page |
||
| 484 | * $I->amOnPage('/register'); |
||
| 485 | * ``` |
||
| 486 | * |
||
| 487 | * @param $page |
||
| 488 | * @see \Codeception\Lib\InnerBrowser::amOnPage() |
||
| 489 | */ |
||
| 490 | public function amOnPage($page) { |
||
| 493 | |||
| 494 | |||
| 495 | /** |
||
| 496 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 497 | * |
||
| 498 | * Perform a click on a link or a button, given by a locator. |
||
| 499 | * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. |
||
| 500 | * For buttons, the "value" attribute, "name" attribute, and inner text are searched. |
||
| 501 | * For links, the link text is searched. |
||
| 502 | * For images, the "alt" attribute and inner text of any parent links are searched. |
||
| 503 | * |
||
| 504 | * The second parameter is a context (CSS or XPath locator) to narrow the search. |
||
| 505 | * |
||
| 506 | * Note that if the locator matches a button of type `submit`, the form will be submitted. |
||
| 507 | * |
||
| 508 | * ``` php |
||
| 509 | * <?php |
||
| 510 | * // simple link |
||
| 511 | * $I->click('Logout'); |
||
| 512 | * // button of form |
||
| 513 | * $I->click('Submit'); |
||
| 514 | * // CSS button |
||
| 515 | * $I->click('#form input[type=submit]'); |
||
| 516 | * // XPath |
||
| 517 | * $I->click('//form/*[@type=submit]'); |
||
| 518 | * // link in context |
||
| 519 | * $I->click('Logout', '#nav'); |
||
| 520 | * // using strict locator |
||
| 521 | * $I->click(['link' => 'Login']); |
||
| 522 | * ?> |
||
| 523 | * ``` |
||
| 524 | * |
||
| 525 | * @param $link |
||
| 526 | * @param $context |
||
| 527 | * @see \Codeception\Lib\InnerBrowser::click() |
||
| 528 | */ |
||
| 529 | public function click($link, $context = null) { |
||
| 532 | |||
| 533 | |||
| 534 | /** |
||
| 535 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 536 | * |
||
| 537 | * Checks that the current page contains the given string (case insensitive). |
||
| 538 | * |
||
| 539 | * You can specify a specific HTML element (via CSS or XPath) as the second |
||
| 540 | * parameter to only search within that element. |
||
| 541 | * |
||
| 542 | * ``` php |
||
| 543 | * <?php |
||
| 544 | * $I->see('Logout'); // I can suppose user is logged in |
||
| 545 | * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page |
||
| 546 | * $I->see('Sign Up', '//body/h1'); // with XPath |
||
| 547 | * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator |
||
| 548 | * ``` |
||
| 549 | * |
||
| 550 | * Note that the search is done after stripping all HTML tags from the body, |
||
| 551 | * so `$I->see('strong')` will return true for strings like: |
||
| 552 | * |
||
| 553 | * - `<p>I am Stronger than thou</p>` |
||
| 554 | * - `<script>document.createElement('strong');</script>` |
||
| 555 | * |
||
| 556 | * But will *not* be true for strings like: |
||
| 557 | * |
||
| 558 | * - `<strong>Home</strong>` |
||
| 559 | * - `<div class="strong">Home</strong>` |
||
| 560 | * - `<!-- strong -->` |
||
| 561 | * |
||
| 562 | * For checking the raw source code, use `seeInSource()`. |
||
| 563 | * |
||
| 564 | * @param $text |
||
| 565 | * @param null $selector |
||
| 566 | * Conditional Assertion: Test won't be stopped on fail |
||
| 567 | * @see \Codeception\Lib\InnerBrowser::see() |
||
| 568 | */ |
||
| 569 | public function canSee($text, $selector = null) { |
||
| 572 | /** |
||
| 573 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 574 | * |
||
| 575 | * Checks that the current page contains the given string (case insensitive). |
||
| 576 | * |
||
| 577 | * You can specify a specific HTML element (via CSS or XPath) as the second |
||
| 578 | * parameter to only search within that element. |
||
| 579 | * |
||
| 580 | * ``` php |
||
| 581 | * <?php |
||
| 582 | * $I->see('Logout'); // I can suppose user is logged in |
||
| 583 | * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page |
||
| 584 | * $I->see('Sign Up', '//body/h1'); // with XPath |
||
| 585 | * $I->see('Sign Up', ['css' => 'body h1']); // with strict CSS locator |
||
| 586 | * ``` |
||
| 587 | * |
||
| 588 | * Note that the search is done after stripping all HTML tags from the body, |
||
| 589 | * so `$I->see('strong')` will return true for strings like: |
||
| 590 | * |
||
| 591 | * - `<p>I am Stronger than thou</p>` |
||
| 592 | * - `<script>document.createElement('strong');</script>` |
||
| 593 | * |
||
| 594 | * But will *not* be true for strings like: |
||
| 595 | * |
||
| 596 | * - `<strong>Home</strong>` |
||
| 597 | * - `<div class="strong">Home</strong>` |
||
| 598 | * - `<!-- strong -->` |
||
| 599 | * |
||
| 600 | * For checking the raw source code, use `seeInSource()`. |
||
| 601 | * |
||
| 602 | * @param $text |
||
| 603 | * @param null $selector |
||
| 604 | * @see \Codeception\Lib\InnerBrowser::see() |
||
| 605 | */ |
||
| 606 | public function see($text, $selector = null) { |
||
| 609 | |||
| 610 | |||
| 611 | /** |
||
| 612 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 613 | * |
||
| 614 | * Checks that the current page doesn't contain the text specified (case insensitive). |
||
| 615 | * Give a locator as the second parameter to match a specific region. |
||
| 616 | * |
||
| 617 | * ```php |
||
| 618 | * <?php |
||
| 619 | * $I->dontSee('Login'); // I can suppose user is already logged in |
||
| 620 | * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page |
||
| 621 | * $I->dontSee('Sign Up','//body/h1'); // with XPath |
||
| 622 | * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator |
||
| 623 | * ``` |
||
| 624 | * |
||
| 625 | * Note that the search is done after stripping all HTML tags from the body, |
||
| 626 | * so `$I->dontSee('strong')` will fail on strings like: |
||
| 627 | * |
||
| 628 | * - `<p>I am Stronger than thou</p>` |
||
| 629 | * - `<script>document.createElement('strong');</script>` |
||
| 630 | * |
||
| 631 | * But will ignore strings like: |
||
| 632 | * |
||
| 633 | * - `<strong>Home</strong>` |
||
| 634 | * - `<div class="strong">Home</strong>` |
||
| 635 | * - `<!-- strong -->` |
||
| 636 | * |
||
| 637 | * For checking the raw source code, use `seeInSource()`. |
||
| 638 | * |
||
| 639 | * @param $text |
||
| 640 | * @param null $selector |
||
| 641 | * Conditional Assertion: Test won't be stopped on fail |
||
| 642 | * @see \Codeception\Lib\InnerBrowser::dontSee() |
||
| 643 | */ |
||
| 644 | public function cantSee($text, $selector = null) { |
||
| 647 | /** |
||
| 648 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 649 | * |
||
| 650 | * Checks that the current page doesn't contain the text specified (case insensitive). |
||
| 651 | * Give a locator as the second parameter to match a specific region. |
||
| 652 | * |
||
| 653 | * ```php |
||
| 654 | * <?php |
||
| 655 | * $I->dontSee('Login'); // I can suppose user is already logged in |
||
| 656 | * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page |
||
| 657 | * $I->dontSee('Sign Up','//body/h1'); // with XPath |
||
| 658 | * $I->dontSee('Sign Up', ['css' => 'body h1']); // with strict CSS locator |
||
| 659 | * ``` |
||
| 660 | * |
||
| 661 | * Note that the search is done after stripping all HTML tags from the body, |
||
| 662 | * so `$I->dontSee('strong')` will fail on strings like: |
||
| 663 | * |
||
| 664 | * - `<p>I am Stronger than thou</p>` |
||
| 665 | * - `<script>document.createElement('strong');</script>` |
||
| 666 | * |
||
| 667 | * But will ignore strings like: |
||
| 668 | * |
||
| 669 | * - `<strong>Home</strong>` |
||
| 670 | * - `<div class="strong">Home</strong>` |
||
| 671 | * - `<!-- strong -->` |
||
| 672 | * |
||
| 673 | * For checking the raw source code, use `seeInSource()`. |
||
| 674 | * |
||
| 675 | * @param $text |
||
| 676 | * @param null $selector |
||
| 677 | * @see \Codeception\Lib\InnerBrowser::dontSee() |
||
| 678 | */ |
||
| 679 | public function dontSee($text, $selector = null) { |
||
| 682 | |||
| 683 | |||
| 684 | /** |
||
| 685 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 686 | * |
||
| 687 | * Checks that the current page contains the given string in its |
||
| 688 | * raw source code. |
||
| 689 | * |
||
| 690 | * ``` php |
||
| 691 | * <?php |
||
| 692 | * $I->seeInSource('<h1>Green eggs & ham</h1>'); |
||
| 693 | * ``` |
||
| 694 | * |
||
| 695 | * @param $raw |
||
| 696 | * Conditional Assertion: Test won't be stopped on fail |
||
| 697 | * @see \Codeception\Lib\InnerBrowser::seeInSource() |
||
| 698 | */ |
||
| 699 | public function canSeeInSource($raw) { |
||
| 702 | /** |
||
| 703 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 704 | * |
||
| 705 | * Checks that the current page contains the given string in its |
||
| 706 | * raw source code. |
||
| 707 | * |
||
| 708 | * ``` php |
||
| 709 | * <?php |
||
| 710 | * $I->seeInSource('<h1>Green eggs & ham</h1>'); |
||
| 711 | * ``` |
||
| 712 | * |
||
| 713 | * @param $raw |
||
| 714 | * @see \Codeception\Lib\InnerBrowser::seeInSource() |
||
| 715 | */ |
||
| 716 | public function seeInSource($raw) { |
||
| 719 | |||
| 720 | |||
| 721 | /** |
||
| 722 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 723 | * |
||
| 724 | * Checks that the current page contains the given string in its |
||
| 725 | * raw source code. |
||
| 726 | * |
||
| 727 | * ```php |
||
| 728 | * <?php |
||
| 729 | * $I->dontSeeInSource('<h1>Green eggs & ham</h1>'); |
||
| 730 | * ``` |
||
| 731 | * |
||
| 732 | * @param $raw |
||
| 733 | * Conditional Assertion: Test won't be stopped on fail |
||
| 734 | * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() |
||
| 735 | */ |
||
| 736 | public function cantSeeInSource($raw) { |
||
| 739 | /** |
||
| 740 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 741 | * |
||
| 742 | * Checks that the current page contains the given string in its |
||
| 743 | * raw source code. |
||
| 744 | * |
||
| 745 | * ```php |
||
| 746 | * <?php |
||
| 747 | * $I->dontSeeInSource('<h1>Green eggs & ham</h1>'); |
||
| 748 | * ``` |
||
| 749 | * |
||
| 750 | * @param $raw |
||
| 751 | * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() |
||
| 752 | */ |
||
| 753 | public function dontSeeInSource($raw) { |
||
| 756 | |||
| 757 | |||
| 758 | /** |
||
| 759 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 760 | * |
||
| 761 | * Checks that there's a link with the specified text. |
||
| 762 | * Give a full URL as the second parameter to match links with that exact URL. |
||
| 763 | * |
||
| 764 | * ``` php |
||
| 765 | * <?php |
||
| 766 | * $I->seeLink('Logout'); // matches <a href="#">Logout</a> |
||
| 767 | * $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a> |
||
| 768 | * ?> |
||
| 769 | * ``` |
||
| 770 | * |
||
| 771 | * @param $text |
||
| 772 | * @param null $url |
||
| 773 | * Conditional Assertion: Test won't be stopped on fail |
||
| 774 | * @see \Codeception\Lib\InnerBrowser::seeLink() |
||
| 775 | */ |
||
| 776 | public function canSeeLink($text, $url = null) { |
||
| 779 | /** |
||
| 780 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 781 | * |
||
| 782 | * Checks that there's a link with the specified text. |
||
| 783 | * Give a full URL as the second parameter to match links with that exact URL. |
||
| 784 | * |
||
| 785 | * ``` php |
||
| 786 | * <?php |
||
| 787 | * $I->seeLink('Logout'); // matches <a href="#">Logout</a> |
||
| 788 | * $I->seeLink('Logout','/logout'); // matches <a href="/logout">Logout</a> |
||
| 789 | * ?> |
||
| 790 | * ``` |
||
| 791 | * |
||
| 792 | * @param $text |
||
| 793 | * @param null $url |
||
| 794 | * @see \Codeception\Lib\InnerBrowser::seeLink() |
||
| 795 | */ |
||
| 796 | public function seeLink($text, $url = null) { |
||
| 799 | |||
| 800 | |||
| 801 | /** |
||
| 802 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 803 | * |
||
| 804 | * Checks that the page doesn't contain a link with the given string. |
||
| 805 | * If the second parameter is given, only links with a matching "href" attribute will be checked. |
||
| 806 | * |
||
| 807 | * ``` php |
||
| 808 | * <?php |
||
| 809 | * $I->dontSeeLink('Logout'); // I suppose user is not logged in |
||
| 810 | * $I->dontSeeLink('Checkout now', '/store/cart.php'); |
||
| 811 | * ?> |
||
| 812 | * ``` |
||
| 813 | * |
||
| 814 | * @param $text |
||
| 815 | * @param null $url |
||
| 816 | * Conditional Assertion: Test won't be stopped on fail |
||
| 817 | * @see \Codeception\Lib\InnerBrowser::dontSeeLink() |
||
| 818 | */ |
||
| 819 | public function cantSeeLink($text, $url = null) { |
||
| 822 | /** |
||
| 823 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 824 | * |
||
| 825 | * Checks that the page doesn't contain a link with the given string. |
||
| 826 | * If the second parameter is given, only links with a matching "href" attribute will be checked. |
||
| 827 | * |
||
| 828 | * ``` php |
||
| 829 | * <?php |
||
| 830 | * $I->dontSeeLink('Logout'); // I suppose user is not logged in |
||
| 831 | * $I->dontSeeLink('Checkout now', '/store/cart.php'); |
||
| 832 | * ?> |
||
| 833 | * ``` |
||
| 834 | * |
||
| 835 | * @param $text |
||
| 836 | * @param null $url |
||
| 837 | * @see \Codeception\Lib\InnerBrowser::dontSeeLink() |
||
| 838 | */ |
||
| 839 | public function dontSeeLink($text, $url = null) { |
||
| 842 | |||
| 843 | |||
| 844 | /** |
||
| 845 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 846 | * |
||
| 847 | * Checks that current URI contains the given string. |
||
| 848 | * |
||
| 849 | * ``` php |
||
| 850 | * <?php |
||
| 851 | * // to match: /home/dashboard |
||
| 852 | * $I->seeInCurrentUrl('home'); |
||
| 853 | * // to match: /users/1 |
||
| 854 | * $I->seeInCurrentUrl('/users/'); |
||
| 855 | * ?> |
||
| 856 | * ``` |
||
| 857 | * |
||
| 858 | * @param $uri |
||
| 859 | * Conditional Assertion: Test won't be stopped on fail |
||
| 860 | * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() |
||
| 861 | */ |
||
| 862 | public function canSeeInCurrentUrl($uri) { |
||
| 865 | /** |
||
| 866 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 867 | * |
||
| 868 | * Checks that current URI contains the given string. |
||
| 869 | * |
||
| 870 | * ``` php |
||
| 871 | * <?php |
||
| 872 | * // to match: /home/dashboard |
||
| 873 | * $I->seeInCurrentUrl('home'); |
||
| 874 | * // to match: /users/1 |
||
| 875 | * $I->seeInCurrentUrl('/users/'); |
||
| 876 | * ?> |
||
| 877 | * ``` |
||
| 878 | * |
||
| 879 | * @param $uri |
||
| 880 | * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() |
||
| 881 | */ |
||
| 882 | public function seeInCurrentUrl($uri) { |
||
| 885 | |||
| 886 | |||
| 887 | /** |
||
| 888 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 889 | * |
||
| 890 | * Checks that the current URI doesn't contain the given string. |
||
| 891 | * |
||
| 892 | * ``` php |
||
| 893 | * <?php |
||
| 894 | * $I->dontSeeInCurrentUrl('/users/'); |
||
| 895 | * ?> |
||
| 896 | * ``` |
||
| 897 | * |
||
| 898 | * @param $uri |
||
| 899 | * Conditional Assertion: Test won't be stopped on fail |
||
| 900 | * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() |
||
| 901 | */ |
||
| 902 | public function cantSeeInCurrentUrl($uri) { |
||
| 905 | /** |
||
| 906 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 907 | * |
||
| 908 | * Checks that the current URI doesn't contain the given string. |
||
| 909 | * |
||
| 910 | * ``` php |
||
| 911 | * <?php |
||
| 912 | * $I->dontSeeInCurrentUrl('/users/'); |
||
| 913 | * ?> |
||
| 914 | * ``` |
||
| 915 | * |
||
| 916 | * @param $uri |
||
| 917 | * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() |
||
| 918 | */ |
||
| 919 | public function dontSeeInCurrentUrl($uri) { |
||
| 922 | |||
| 923 | |||
| 924 | /** |
||
| 925 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 926 | * |
||
| 927 | * Checks that the current URL is equal to the given string. |
||
| 928 | * Unlike `seeInCurrentUrl`, this only matches the full URL. |
||
| 929 | * |
||
| 930 | * ``` php |
||
| 931 | * <?php |
||
| 932 | * // to match root url |
||
| 933 | * $I->seeCurrentUrlEquals('/'); |
||
| 934 | * ?> |
||
| 935 | * ``` |
||
| 936 | * |
||
| 937 | * @param $uri |
||
| 938 | * Conditional Assertion: Test won't be stopped on fail |
||
| 939 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() |
||
| 940 | */ |
||
| 941 | public function canSeeCurrentUrlEquals($uri) { |
||
| 944 | /** |
||
| 945 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 946 | * |
||
| 947 | * Checks that the current URL is equal to the given string. |
||
| 948 | * Unlike `seeInCurrentUrl`, this only matches the full URL. |
||
| 949 | * |
||
| 950 | * ``` php |
||
| 951 | * <?php |
||
| 952 | * // to match root url |
||
| 953 | * $I->seeCurrentUrlEquals('/'); |
||
| 954 | * ?> |
||
| 955 | * ``` |
||
| 956 | * |
||
| 957 | * @param $uri |
||
| 958 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() |
||
| 959 | */ |
||
| 960 | public function seeCurrentUrlEquals($uri) { |
||
| 963 | |||
| 964 | |||
| 965 | /** |
||
| 966 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 967 | * |
||
| 968 | * Checks that the current URL doesn't equal the given string. |
||
| 969 | * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. |
||
| 970 | * |
||
| 971 | * ``` php |
||
| 972 | * <?php |
||
| 973 | * // current url is not root |
||
| 974 | * $I->dontSeeCurrentUrlEquals('/'); |
||
| 975 | * ?> |
||
| 976 | * ``` |
||
| 977 | * |
||
| 978 | * @param $uri |
||
| 979 | * Conditional Assertion: Test won't be stopped on fail |
||
| 980 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() |
||
| 981 | */ |
||
| 982 | public function cantSeeCurrentUrlEquals($uri) { |
||
| 985 | /** |
||
| 986 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 987 | * |
||
| 988 | * Checks that the current URL doesn't equal the given string. |
||
| 989 | * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. |
||
| 990 | * |
||
| 991 | * ``` php |
||
| 992 | * <?php |
||
| 993 | * // current url is not root |
||
| 994 | * $I->dontSeeCurrentUrlEquals('/'); |
||
| 995 | * ?> |
||
| 996 | * ``` |
||
| 997 | * |
||
| 998 | * @param $uri |
||
| 999 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() |
||
| 1000 | */ |
||
| 1001 | public function dontSeeCurrentUrlEquals($uri) { |
||
| 1004 | |||
| 1005 | |||
| 1006 | /** |
||
| 1007 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1008 | * |
||
| 1009 | * Checks that the current URL matches the given regular expression. |
||
| 1010 | * |
||
| 1011 | * ``` php |
||
| 1012 | * <?php |
||
| 1013 | * // to match root url |
||
| 1014 | * $I->seeCurrentUrlMatches('~$/users/(\d+)~'); |
||
| 1015 | * ?> |
||
| 1016 | * ``` |
||
| 1017 | * |
||
| 1018 | * @param $uri |
||
| 1019 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1020 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() |
||
| 1021 | */ |
||
| 1022 | public function canSeeCurrentUrlMatches($uri) { |
||
| 1025 | /** |
||
| 1026 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1027 | * |
||
| 1028 | * Checks that the current URL matches the given regular expression. |
||
| 1029 | * |
||
| 1030 | * ``` php |
||
| 1031 | * <?php |
||
| 1032 | * // to match root url |
||
| 1033 | * $I->seeCurrentUrlMatches('~$/users/(\d+)~'); |
||
| 1034 | * ?> |
||
| 1035 | * ``` |
||
| 1036 | * |
||
| 1037 | * @param $uri |
||
| 1038 | * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() |
||
| 1039 | */ |
||
| 1040 | public function seeCurrentUrlMatches($uri) { |
||
| 1043 | |||
| 1044 | |||
| 1045 | /** |
||
| 1046 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1047 | * |
||
| 1048 | * Checks that current url doesn't match the given regular expression. |
||
| 1049 | * |
||
| 1050 | * ``` php |
||
| 1051 | * <?php |
||
| 1052 | * // to match root url |
||
| 1053 | * $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~'); |
||
| 1054 | * ?> |
||
| 1055 | * ``` |
||
| 1056 | * |
||
| 1057 | * @param $uri |
||
| 1058 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1059 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() |
||
| 1060 | */ |
||
| 1061 | public function cantSeeCurrentUrlMatches($uri) { |
||
| 1064 | /** |
||
| 1065 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1066 | * |
||
| 1067 | * Checks that current url doesn't match the given regular expression. |
||
| 1068 | * |
||
| 1069 | * ``` php |
||
| 1070 | * <?php |
||
| 1071 | * // to match root url |
||
| 1072 | * $I->dontSeeCurrentUrlMatches('~$/users/(\d+)~'); |
||
| 1073 | * ?> |
||
| 1074 | * ``` |
||
| 1075 | * |
||
| 1076 | * @param $uri |
||
| 1077 | * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() |
||
| 1078 | */ |
||
| 1079 | public function dontSeeCurrentUrlMatches($uri) { |
||
| 1082 | |||
| 1083 | |||
| 1084 | /** |
||
| 1085 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1086 | * |
||
| 1087 | * Executes the given regular expression against the current URI and returns the first match. |
||
| 1088 | * If no parameters are provided, the full URI is returned. |
||
| 1089 | * |
||
| 1090 | * ``` php |
||
| 1091 | * <?php |
||
| 1092 | * $user_id = $I->grabFromCurrentUrl('~$/user/(\d+)/~'); |
||
| 1093 | * $uri = $I->grabFromCurrentUrl(); |
||
| 1094 | * ?> |
||
| 1095 | * ``` |
||
| 1096 | * |
||
| 1097 | * @param null $uri |
||
| 1098 | * |
||
| 1099 | * @return mixed |
||
| 1100 | * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() |
||
| 1101 | */ |
||
| 1102 | public function grabFromCurrentUrl($uri = null) { |
||
| 1105 | |||
| 1106 | |||
| 1107 | /** |
||
| 1108 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1109 | * |
||
| 1110 | * Checks that the specified checkbox is checked. |
||
| 1111 | * |
||
| 1112 | * ``` php |
||
| 1113 | * <?php |
||
| 1114 | * $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms |
||
| 1115 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. |
||
| 1116 | * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); |
||
| 1117 | * ?> |
||
| 1118 | * ``` |
||
| 1119 | * |
||
| 1120 | * @param $checkbox |
||
| 1121 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1122 | * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() |
||
| 1123 | */ |
||
| 1124 | public function canSeeCheckboxIsChecked($checkbox) { |
||
| 1127 | /** |
||
| 1128 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1129 | * |
||
| 1130 | * Checks that the specified checkbox is checked. |
||
| 1131 | * |
||
| 1132 | * ``` php |
||
| 1133 | * <?php |
||
| 1134 | * $I->seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms |
||
| 1135 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. |
||
| 1136 | * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); |
||
| 1137 | * ?> |
||
| 1138 | * ``` |
||
| 1139 | * |
||
| 1140 | * @param $checkbox |
||
| 1141 | * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() |
||
| 1142 | */ |
||
| 1143 | public function seeCheckboxIsChecked($checkbox) { |
||
| 1146 | |||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1150 | * |
||
| 1151 | * Check that the specified checkbox is unchecked. |
||
| 1152 | * |
||
| 1153 | * ``` php |
||
| 1154 | * <?php |
||
| 1155 | * $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms |
||
| 1156 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. |
||
| 1157 | * ?> |
||
| 1158 | * ``` |
||
| 1159 | * |
||
| 1160 | * @param $checkbox |
||
| 1161 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1162 | * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() |
||
| 1163 | */ |
||
| 1164 | public function cantSeeCheckboxIsChecked($checkbox) { |
||
| 1167 | /** |
||
| 1168 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1169 | * |
||
| 1170 | * Check that the specified checkbox is unchecked. |
||
| 1171 | * |
||
| 1172 | * ``` php |
||
| 1173 | * <?php |
||
| 1174 | * $I->dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms |
||
| 1175 | * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. |
||
| 1176 | * ?> |
||
| 1177 | * ``` |
||
| 1178 | * |
||
| 1179 | * @param $checkbox |
||
| 1180 | * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() |
||
| 1181 | */ |
||
| 1182 | public function dontSeeCheckboxIsChecked($checkbox) { |
||
| 1185 | |||
| 1186 | |||
| 1187 | /** |
||
| 1188 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1189 | * |
||
| 1190 | * Checks that the given input field or textarea contains the given value. |
||
| 1191 | * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. |
||
| 1192 | * |
||
| 1193 | * ``` php |
||
| 1194 | * <?php |
||
| 1195 | * $I->seeInField('Body','Type your comment here'); |
||
| 1196 | * $I->seeInField('form textarea[name=body]','Type your comment here'); |
||
| 1197 | * $I->seeInField('form input[type=hidden]','hidden_value'); |
||
| 1198 | * $I->seeInField('#searchform input','Search'); |
||
| 1199 | * $I->seeInField('//form/*[@name=search]','Search'); |
||
| 1200 | * $I->seeInField(['name' => 'search'], 'Search'); |
||
| 1201 | * ?> |
||
| 1202 | * ``` |
||
| 1203 | * |
||
| 1204 | * @param $field |
||
| 1205 | * @param $value |
||
| 1206 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1207 | * @see \Codeception\Lib\InnerBrowser::seeInField() |
||
| 1208 | */ |
||
| 1209 | public function canSeeInField($field, $value) { |
||
| 1212 | /** |
||
| 1213 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1214 | * |
||
| 1215 | * Checks that the given input field or textarea contains the given value. |
||
| 1216 | * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. |
||
| 1217 | * |
||
| 1218 | * ``` php |
||
| 1219 | * <?php |
||
| 1220 | * $I->seeInField('Body','Type your comment here'); |
||
| 1221 | * $I->seeInField('form textarea[name=body]','Type your comment here'); |
||
| 1222 | * $I->seeInField('form input[type=hidden]','hidden_value'); |
||
| 1223 | * $I->seeInField('#searchform input','Search'); |
||
| 1224 | * $I->seeInField('//form/*[@name=search]','Search'); |
||
| 1225 | * $I->seeInField(['name' => 'search'], 'Search'); |
||
| 1226 | * ?> |
||
| 1227 | * ``` |
||
| 1228 | * |
||
| 1229 | * @param $field |
||
| 1230 | * @param $value |
||
| 1231 | * @see \Codeception\Lib\InnerBrowser::seeInField() |
||
| 1232 | */ |
||
| 1233 | public function seeInField($field, $value) { |
||
| 1236 | |||
| 1237 | |||
| 1238 | /** |
||
| 1239 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1240 | * |
||
| 1241 | * Checks that an input field or textarea doesn't contain the given value. |
||
| 1242 | * For fuzzy locators, the field is matched by label text, CSS and XPath. |
||
| 1243 | * |
||
| 1244 | * ``` php |
||
| 1245 | * <?php |
||
| 1246 | * $I->dontSeeInField('Body','Type your comment here'); |
||
| 1247 | * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); |
||
| 1248 | * $I->dontSeeInField('form input[type=hidden]','hidden_value'); |
||
| 1249 | * $I->dontSeeInField('#searchform input','Search'); |
||
| 1250 | * $I->dontSeeInField('//form/*[@name=search]','Search'); |
||
| 1251 | * $I->dontSeeInField(['name' => 'search'], 'Search'); |
||
| 1252 | * ?> |
||
| 1253 | * ``` |
||
| 1254 | * |
||
| 1255 | * @param $field |
||
| 1256 | * @param $value |
||
| 1257 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1258 | * @see \Codeception\Lib\InnerBrowser::dontSeeInField() |
||
| 1259 | */ |
||
| 1260 | public function cantSeeInField($field, $value) { |
||
| 1263 | /** |
||
| 1264 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1265 | * |
||
| 1266 | * Checks that an input field or textarea doesn't contain the given value. |
||
| 1267 | * For fuzzy locators, the field is matched by label text, CSS and XPath. |
||
| 1268 | * |
||
| 1269 | * ``` php |
||
| 1270 | * <?php |
||
| 1271 | * $I->dontSeeInField('Body','Type your comment here'); |
||
| 1272 | * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); |
||
| 1273 | * $I->dontSeeInField('form input[type=hidden]','hidden_value'); |
||
| 1274 | * $I->dontSeeInField('#searchform input','Search'); |
||
| 1275 | * $I->dontSeeInField('//form/*[@name=search]','Search'); |
||
| 1276 | * $I->dontSeeInField(['name' => 'search'], 'Search'); |
||
| 1277 | * ?> |
||
| 1278 | * ``` |
||
| 1279 | * |
||
| 1280 | * @param $field |
||
| 1281 | * @param $value |
||
| 1282 | * @see \Codeception\Lib\InnerBrowser::dontSeeInField() |
||
| 1283 | */ |
||
| 1284 | public function dontSeeInField($field, $value) { |
||
| 1287 | |||
| 1288 | |||
| 1289 | /** |
||
| 1290 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1291 | * |
||
| 1292 | * Checks if the array of form parameters (name => value) are set on the form matched with the |
||
| 1293 | * passed selector. |
||
| 1294 | * |
||
| 1295 | * ``` php |
||
| 1296 | * <?php |
||
| 1297 | * $I->seeInFormFields('form[name=myform]', [ |
||
| 1298 | * 'input1' => 'value', |
||
| 1299 | * 'input2' => 'other value', |
||
| 1300 | * ]); |
||
| 1301 | * ?> |
||
| 1302 | * ``` |
||
| 1303 | * |
||
| 1304 | * For multi-select elements, or to check values of multiple elements with the same name, an |
||
| 1305 | * array may be passed: |
||
| 1306 | * |
||
| 1307 | * ``` php |
||
| 1308 | * <?php |
||
| 1309 | * $I->seeInFormFields('.form-class', [ |
||
| 1310 | * 'multiselect' => [ |
||
| 1311 | * 'value1', |
||
| 1312 | * 'value2', |
||
| 1313 | * ], |
||
| 1314 | * 'checkbox[]' => [ |
||
| 1315 | * 'a checked value', |
||
| 1316 | * 'another checked value', |
||
| 1317 | * ], |
||
| 1318 | * ]); |
||
| 1319 | * ?> |
||
| 1320 | * ``` |
||
| 1321 | * |
||
| 1322 | * Additionally, checkbox values can be checked with a boolean. |
||
| 1323 | * |
||
| 1324 | * ``` php |
||
| 1325 | * <?php |
||
| 1326 | * $I->seeInFormFields('#form-id', [ |
||
| 1327 | * 'checkbox1' => true, // passes if checked |
||
| 1328 | * 'checkbox2' => false, // passes if unchecked |
||
| 1329 | * ]); |
||
| 1330 | * ?> |
||
| 1331 | * ``` |
||
| 1332 | * |
||
| 1333 | * Pair this with submitForm for quick testing magic. |
||
| 1334 | * |
||
| 1335 | * ``` php |
||
| 1336 | * <?php |
||
| 1337 | * $form = [ |
||
| 1338 | * 'field1' => 'value', |
||
| 1339 | * 'field2' => 'another value', |
||
| 1340 | * 'checkbox1' => true, |
||
| 1341 | * // ... |
||
| 1342 | * ]; |
||
| 1343 | * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); |
||
| 1344 | * // $I->amOnPage('/path/to/form-page') may be needed |
||
| 1345 | * $I->seeInFormFields('//form[@id=my-form]', $form); |
||
| 1346 | * ?> |
||
| 1347 | * ``` |
||
| 1348 | * |
||
| 1349 | * @param $formSelector |
||
| 1350 | * @param $params |
||
| 1351 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1352 | * @see \Codeception\Lib\InnerBrowser::seeInFormFields() |
||
| 1353 | */ |
||
| 1354 | public function canSeeInFormFields($formSelector, $params) { |
||
| 1357 | /** |
||
| 1358 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1359 | * |
||
| 1360 | * Checks if the array of form parameters (name => value) are set on the form matched with the |
||
| 1361 | * passed selector. |
||
| 1362 | * |
||
| 1363 | * ``` php |
||
| 1364 | * <?php |
||
| 1365 | * $I->seeInFormFields('form[name=myform]', [ |
||
| 1366 | * 'input1' => 'value', |
||
| 1367 | * 'input2' => 'other value', |
||
| 1368 | * ]); |
||
| 1369 | * ?> |
||
| 1370 | * ``` |
||
| 1371 | * |
||
| 1372 | * For multi-select elements, or to check values of multiple elements with the same name, an |
||
| 1373 | * array may be passed: |
||
| 1374 | * |
||
| 1375 | * ``` php |
||
| 1376 | * <?php |
||
| 1377 | * $I->seeInFormFields('.form-class', [ |
||
| 1378 | * 'multiselect' => [ |
||
| 1379 | * 'value1', |
||
| 1380 | * 'value2', |
||
| 1381 | * ], |
||
| 1382 | * 'checkbox[]' => [ |
||
| 1383 | * 'a checked value', |
||
| 1384 | * 'another checked value', |
||
| 1385 | * ], |
||
| 1386 | * ]); |
||
| 1387 | * ?> |
||
| 1388 | * ``` |
||
| 1389 | * |
||
| 1390 | * Additionally, checkbox values can be checked with a boolean. |
||
| 1391 | * |
||
| 1392 | * ``` php |
||
| 1393 | * <?php |
||
| 1394 | * $I->seeInFormFields('#form-id', [ |
||
| 1395 | * 'checkbox1' => true, // passes if checked |
||
| 1396 | * 'checkbox2' => false, // passes if unchecked |
||
| 1397 | * ]); |
||
| 1398 | * ?> |
||
| 1399 | * ``` |
||
| 1400 | * |
||
| 1401 | * Pair this with submitForm for quick testing magic. |
||
| 1402 | * |
||
| 1403 | * ``` php |
||
| 1404 | * <?php |
||
| 1405 | * $form = [ |
||
| 1406 | * 'field1' => 'value', |
||
| 1407 | * 'field2' => 'another value', |
||
| 1408 | * 'checkbox1' => true, |
||
| 1409 | * // ... |
||
| 1410 | * ]; |
||
| 1411 | * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); |
||
| 1412 | * // $I->amOnPage('/path/to/form-page') may be needed |
||
| 1413 | * $I->seeInFormFields('//form[@id=my-form]', $form); |
||
| 1414 | * ?> |
||
| 1415 | * ``` |
||
| 1416 | * |
||
| 1417 | * @param $formSelector |
||
| 1418 | * @param $params |
||
| 1419 | * @see \Codeception\Lib\InnerBrowser::seeInFormFields() |
||
| 1420 | */ |
||
| 1421 | public function seeInFormFields($formSelector, $params) { |
||
| 1424 | |||
| 1425 | |||
| 1426 | /** |
||
| 1427 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1428 | * |
||
| 1429 | * Checks if the array of form parameters (name => value) are not set on the form matched with |
||
| 1430 | * the passed selector. |
||
| 1431 | * |
||
| 1432 | * ``` php |
||
| 1433 | * <?php |
||
| 1434 | * $I->dontSeeInFormFields('form[name=myform]', [ |
||
| 1435 | * 'input1' => 'non-existent value', |
||
| 1436 | * 'input2' => 'other non-existent value', |
||
| 1437 | * ]); |
||
| 1438 | * ?> |
||
| 1439 | * ``` |
||
| 1440 | * |
||
| 1441 | * To check that an element hasn't been assigned any one of many values, an array can be passed |
||
| 1442 | * as the value: |
||
| 1443 | * |
||
| 1444 | * ``` php |
||
| 1445 | * <?php |
||
| 1446 | * $I->dontSeeInFormFields('.form-class', [ |
||
| 1447 | * 'fieldName' => [ |
||
| 1448 | * 'This value shouldn\'t be set', |
||
| 1449 | * 'And this value shouldn\'t be set', |
||
| 1450 | * ], |
||
| 1451 | * ]); |
||
| 1452 | * ?> |
||
| 1453 | * ``` |
||
| 1454 | * |
||
| 1455 | * Additionally, checkbox values can be checked with a boolean. |
||
| 1456 | * |
||
| 1457 | * ``` php |
||
| 1458 | * <?php |
||
| 1459 | * $I->dontSeeInFormFields('#form-id', [ |
||
| 1460 | * 'checkbox1' => true, // fails if checked |
||
| 1461 | * 'checkbox2' => false, // fails if unchecked |
||
| 1462 | * ]); |
||
| 1463 | * ?> |
||
| 1464 | * ``` |
||
| 1465 | * |
||
| 1466 | * @param $formSelector |
||
| 1467 | * @param $params |
||
| 1468 | * Conditional Assertion: Test won't be stopped on fail |
||
| 1469 | * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() |
||
| 1470 | */ |
||
| 1471 | public function cantSeeInFormFields($formSelector, $params) { |
||
| 1474 | /** |
||
| 1475 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1476 | * |
||
| 1477 | * Checks if the array of form parameters (name => value) are not set on the form matched with |
||
| 1478 | * the passed selector. |
||
| 1479 | * |
||
| 1480 | * ``` php |
||
| 1481 | * <?php |
||
| 1482 | * $I->dontSeeInFormFields('form[name=myform]', [ |
||
| 1483 | * 'input1' => 'non-existent value', |
||
| 1484 | * 'input2' => 'other non-existent value', |
||
| 1485 | * ]); |
||
| 1486 | * ?> |
||
| 1487 | * ``` |
||
| 1488 | * |
||
| 1489 | * To check that an element hasn't been assigned any one of many values, an array can be passed |
||
| 1490 | * as the value: |
||
| 1491 | * |
||
| 1492 | * ``` php |
||
| 1493 | * <?php |
||
| 1494 | * $I->dontSeeInFormFields('.form-class', [ |
||
| 1495 | * 'fieldName' => [ |
||
| 1496 | * 'This value shouldn\'t be set', |
||
| 1497 | * 'And this value shouldn\'t be set', |
||
| 1498 | * ], |
||
| 1499 | * ]); |
||
| 1500 | * ?> |
||
| 1501 | * ``` |
||
| 1502 | * |
||
| 1503 | * Additionally, checkbox values can be checked with a boolean. |
||
| 1504 | * |
||
| 1505 | * ``` php |
||
| 1506 | * <?php |
||
| 1507 | * $I->dontSeeInFormFields('#form-id', [ |
||
| 1508 | * 'checkbox1' => true, // fails if checked |
||
| 1509 | * 'checkbox2' => false, // fails if unchecked |
||
| 1510 | * ]); |
||
| 1511 | * ?> |
||
| 1512 | * ``` |
||
| 1513 | * |
||
| 1514 | * @param $formSelector |
||
| 1515 | * @param $params |
||
| 1516 | * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() |
||
| 1517 | */ |
||
| 1518 | public function dontSeeInFormFields($formSelector, $params) { |
||
| 1521 | |||
| 1522 | |||
| 1523 | /** |
||
| 1524 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1525 | * |
||
| 1526 | * Submits the given form on the page, with the given form |
||
| 1527 | * values. Pass the form field's values as an array in the second |
||
| 1528 | * parameter. |
||
| 1529 | * |
||
| 1530 | * Although this function can be used as a short-hand version of |
||
| 1531 | * `fillField()`, `selectOption()`, `click()` etc. it has some important |
||
| 1532 | * differences: |
||
| 1533 | * |
||
| 1534 | * * Only field *names* may be used, not CSS/XPath selectors nor field labels |
||
| 1535 | * * If a field is sent to this function that does *not* exist on the page, |
||
| 1536 | * it will silently be added to the HTTP request. This is helpful for testing |
||
| 1537 | * some types of forms, but be aware that you will *not* get an exception |
||
| 1538 | * like you would if you called `fillField()` or `selectOption()` with |
||
| 1539 | * a missing field. |
||
| 1540 | * |
||
| 1541 | * Fields that are not provided will be filled by their values from the page, |
||
| 1542 | * or from any previous calls to `fillField()`, `selectOption()` etc. |
||
| 1543 | * You don't need to click the 'Submit' button afterwards. |
||
| 1544 | * This command itself triggers the request to form's action. |
||
| 1545 | * |
||
| 1546 | * You can optionally specify which button's value to include |
||
| 1547 | * in the request with the last parameter (as an alternative to |
||
| 1548 | * explicitly setting its value in the second parameter), as |
||
| 1549 | * button values are not otherwise included in the request. |
||
| 1550 | * |
||
| 1551 | * Examples: |
||
| 1552 | * |
||
| 1553 | * ``` php |
||
| 1554 | * <?php |
||
| 1555 | * $I->submitForm('#login', [ |
||
| 1556 | * 'login' => 'davert', |
||
| 1557 | * 'password' => '123456' |
||
| 1558 | * ]); |
||
| 1559 | * // or |
||
| 1560 | * $I->submitForm('#login', [ |
||
| 1561 | * 'login' => 'davert', |
||
| 1562 | * 'password' => '123456' |
||
| 1563 | * ], 'submitButtonName'); |
||
| 1564 | * |
||
| 1565 | * ``` |
||
| 1566 | * |
||
| 1567 | * For example, given this sample "Sign Up" form: |
||
| 1568 | * |
||
| 1569 | * ``` html |
||
| 1570 | * <form action="/sign_up"> |
||
| 1571 | * Login: |
||
| 1572 | * <input type="text" name="user[login]" /><br/> |
||
| 1573 | * Password: |
||
| 1574 | * <input type="password" name="user[password]" /><br/> |
||
| 1575 | * Do you agree to our terms? |
||
| 1576 | * <input type="checkbox" name="user[agree]" /><br/> |
||
| 1577 | * Select pricing plan: |
||
| 1578 | * <select name="plan"> |
||
| 1579 | * <option value="1">Free</option> |
||
| 1580 | * <option value="2" selected="selected">Paid</option> |
||
| 1581 | * </select> |
||
| 1582 | * <input type="submit" name="submitButton" value="Submit" /> |
||
| 1583 | * </form> |
||
| 1584 | * ``` |
||
| 1585 | * |
||
| 1586 | * You could write the following to submit it: |
||
| 1587 | * |
||
| 1588 | * ``` php |
||
| 1589 | * <?php |
||
| 1590 | * $I->submitForm( |
||
| 1591 | * '#userForm', |
||
| 1592 | * [ |
||
| 1593 | * 'user' => [ |
||
| 1594 | * 'login' => 'Davert', |
||
| 1595 | * 'password' => '123456', |
||
| 1596 | * 'agree' => true |
||
| 1597 | * ] |
||
| 1598 | * ], |
||
| 1599 | * 'submitButton' |
||
| 1600 | * ); |
||
| 1601 | * ``` |
||
| 1602 | * Note that "2" will be the submitted value for the "plan" field, as it is |
||
| 1603 | * the selected option. |
||
| 1604 | * |
||
| 1605 | * You can also emulate a JavaScript submission by not specifying any |
||
| 1606 | * buttons in the third parameter to submitForm. |
||
| 1607 | * |
||
| 1608 | * ```php |
||
| 1609 | * <?php |
||
| 1610 | * $I->submitForm( |
||
| 1611 | * '#userForm', |
||
| 1612 | * [ |
||
| 1613 | * 'user' => [ |
||
| 1614 | * 'login' => 'Davert', |
||
| 1615 | * 'password' => '123456', |
||
| 1616 | * 'agree' => true |
||
| 1617 | * ] |
||
| 1618 | * ] |
||
| 1619 | * ); |
||
| 1620 | * ``` |
||
| 1621 | * |
||
| 1622 | * This function works well when paired with `seeInFormFields()` |
||
| 1623 | * for quickly testing CRUD interfaces and form validation logic. |
||
| 1624 | * |
||
| 1625 | * ``` php |
||
| 1626 | * <?php |
||
| 1627 | * $form = [ |
||
| 1628 | * 'field1' => 'value', |
||
| 1629 | * 'field2' => 'another value', |
||
| 1630 | * 'checkbox1' => true, |
||
| 1631 | * // ... |
||
| 1632 | * ]; |
||
| 1633 | * $I->submitForm('#my-form', $form, 'submitButton'); |
||
| 1634 | * // $I->amOnPage('/path/to/form-page') may be needed |
||
| 1635 | * $I->seeInFormFields('#my-form', $form); |
||
| 1636 | * ``` |
||
| 1637 | * |
||
| 1638 | * Parameter values can be set to arrays for multiple input fields |
||
| 1639 | * of the same name, or multi-select combo boxes. For checkboxes, |
||
| 1640 | * you can use either the string value or boolean `true`/`false` which will |
||
| 1641 | * be replaced by the checkbox's value in the DOM. |
||
| 1642 | * |
||
| 1643 | * ``` php |
||
| 1644 | * <?php |
||
| 1645 | * $I->submitForm('#my-form', [ |
||
| 1646 | * 'field1' => 'value', |
||
| 1647 | * 'checkbox' => [ |
||
| 1648 | * 'value of first checkbox', |
||
| 1649 | * 'value of second checkbox', |
||
| 1650 | * ], |
||
| 1651 | * 'otherCheckboxes' => [ |
||
| 1652 | * true, |
||
| 1653 | * false, |
||
| 1654 | * false |
||
| 1655 | * ], |
||
| 1656 | * 'multiselect' => [ |
||
| 1657 | * 'first option value', |
||
| 1658 | * 'second option value' |
||
| 1659 | * ] |
||
| 1660 | * ]); |
||
| 1661 | * ``` |
||
| 1662 | * |
||
| 1663 | * Mixing string and boolean values for a checkbox's value is not supported |
||
| 1664 | * and may produce unexpected results. |
||
| 1665 | * |
||
| 1666 | * Field names ending in `[]` must be passed without the trailing square |
||
| 1667 | * bracket characters, and must contain an array for its value. This allows |
||
| 1668 | * submitting multiple values with the same name, consider: |
||
| 1669 | * |
||
| 1670 | * ```php |
||
| 1671 | * <?php |
||
| 1672 | * // This will NOT work correctly |
||
| 1673 | * $I->submitForm('#my-form', [ |
||
| 1674 | * 'field[]' => 'value', |
||
| 1675 | * 'field[]' => 'another value', // 'field[]' is already a defined key |
||
| 1676 | * ]); |
||
| 1677 | * ``` |
||
| 1678 | * |
||
| 1679 | * The solution is to pass an array value: |
||
| 1680 | * |
||
| 1681 | * ```php |
||
| 1682 | * <?php |
||
| 1683 | * // This way both values are submitted |
||
| 1684 | * $I->submitForm('#my-form', [ |
||
| 1685 | * 'field' => [ |
||
| 1686 | * 'value', |
||
| 1687 | * 'another value', |
||
| 1688 | * ] |
||
| 1689 | * ]); |
||
| 1690 | * ``` |
||
| 1691 | * |
||
| 1692 | * @param $selector |
||
| 1693 | * @param $params |
||
| 1694 | * @param $button |
||
| 1695 | * @see \Codeception\Lib\InnerBrowser::submitForm() |
||
| 1696 | */ |
||
| 1697 | public function submitForm($selector, $params, $button = null) { |
||
| 1700 | |||
| 1701 | |||
| 1702 | /** |
||
| 1703 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1704 | * |
||
| 1705 | * Fills a text field or textarea with the given string. |
||
| 1706 | * |
||
| 1707 | * ``` php |
||
| 1708 | * <?php |
||
| 1709 | * $I->fillField("//input[@type='text']", "Hello World!"); |
||
| 1710 | * $I->fillField(['name' => 'email'], '[email protected]'); |
||
| 1711 | * ?> |
||
| 1712 | * ``` |
||
| 1713 | * |
||
| 1714 | * @param $field |
||
| 1715 | * @param $value |
||
| 1716 | * @see \Codeception\Lib\InnerBrowser::fillField() |
||
| 1717 | */ |
||
| 1718 | public function fillField($field, $value) { |
||
| 1721 | |||
| 1722 | |||
| 1723 | /** |
||
| 1724 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1725 | * |
||
| 1726 | * Selects an option in a select tag or in radio button group. |
||
| 1727 | * |
||
| 1728 | * ``` php |
||
| 1729 | * <?php |
||
| 1730 | * $I->selectOption('form select[name=account]', 'Premium'); |
||
| 1731 | * $I->selectOption('form input[name=payment]', 'Monthly'); |
||
| 1732 | * $I->selectOption('//form/select[@name=account]', 'Monthly'); |
||
| 1733 | * ?> |
||
| 1734 | * ``` |
||
| 1735 | * |
||
| 1736 | * Provide an array for the second argument to select multiple options: |
||
| 1737 | * |
||
| 1738 | * ``` php |
||
| 1739 | * <?php |
||
| 1740 | * $I->selectOption('Which OS do you use?', array('Windows','Linux')); |
||
| 1741 | * ?> |
||
| 1742 | * ``` |
||
| 1743 | * |
||
| 1744 | * Or provide an associative array for the second argument to specifically define which selection method should be used: |
||
| 1745 | * |
||
| 1746 | * ``` php |
||
| 1747 | * <?php |
||
| 1748 | * $I->selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' |
||
| 1749 | * $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' |
||
| 1750 | * ?> |
||
| 1751 | * ``` |
||
| 1752 | * |
||
| 1753 | * @param $select |
||
| 1754 | * @param $option |
||
| 1755 | * @see \Codeception\Lib\InnerBrowser::selectOption() |
||
| 1756 | */ |
||
| 1757 | public function selectOption($select, $option) { |
||
| 1760 | |||
| 1761 | |||
| 1762 | /** |
||
| 1763 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1764 | * |
||
| 1765 | * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. |
||
| 1766 | * |
||
| 1767 | * ``` php |
||
| 1768 | * <?php |
||
| 1769 | * $I->checkOption('#agree'); |
||
| 1770 | * ?> |
||
| 1771 | * ``` |
||
| 1772 | * |
||
| 1773 | * @param $option |
||
| 1774 | * @see \Codeception\Lib\InnerBrowser::checkOption() |
||
| 1775 | */ |
||
| 1776 | public function checkOption($option) { |
||
| 1779 | |||
| 1780 | |||
| 1781 | /** |
||
| 1782 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1783 | * |
||
| 1784 | * Unticks a checkbox. |
||
| 1785 | * |
||
| 1786 | * ``` php |
||
| 1787 | * <?php |
||
| 1788 | * $I->uncheckOption('#notify'); |
||
| 1789 | * ?> |
||
| 1790 | * ``` |
||
| 1791 | * |
||
| 1792 | * @param $option |
||
| 1793 | * @see \Codeception\Lib\InnerBrowser::uncheckOption() |
||
| 1794 | */ |
||
| 1795 | public function uncheckOption($option) { |
||
| 1798 | |||
| 1799 | |||
| 1800 | /** |
||
| 1801 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1802 | * |
||
| 1803 | * Attaches a file relative to the Codeception data directory to the given file upload field. |
||
| 1804 | * |
||
| 1805 | * ``` php |
||
| 1806 | * <?php |
||
| 1807 | * // file is stored in 'tests/_data/prices.xls' |
||
| 1808 | * $I->attachFile('input[@type="file"]', 'prices.xls'); |
||
| 1809 | * ?> |
||
| 1810 | * ``` |
||
| 1811 | * |
||
| 1812 | * @param $field |
||
| 1813 | * @param $filename |
||
| 1814 | * @see \Codeception\Lib\InnerBrowser::attachFile() |
||
| 1815 | */ |
||
| 1816 | public function attachFile($field, $filename) { |
||
| 1819 | |||
| 1820 | |||
| 1821 | /** |
||
| 1822 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1823 | * |
||
| 1824 | * If your page triggers an ajax request, you can perform it manually. |
||
| 1825 | * This action sends a GET ajax request with specified params. |
||
| 1826 | * |
||
| 1827 | * See ->sendAjaxPostRequest for examples. |
||
| 1828 | * |
||
| 1829 | * @param $uri |
||
| 1830 | * @param $params |
||
| 1831 | * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() |
||
| 1832 | */ |
||
| 1833 | public function sendAjaxGetRequest($uri, $params = null) { |
||
| 1836 | |||
| 1837 | |||
| 1838 | /** |
||
| 1839 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1840 | * |
||
| 1841 | * If your page triggers an ajax request, you can perform it manually. |
||
| 1842 | * This action sends a POST ajax request with specified params. |
||
| 1843 | * Additional params can be passed as array. |
||
| 1844 | * |
||
| 1845 | * Example: |
||
| 1846 | * |
||
| 1847 | * Imagine that by clicking checkbox you trigger ajax request which updates user settings. |
||
| 1848 | * We emulate that click by running this ajax request manually. |
||
| 1849 | * |
||
| 1850 | * ``` php |
||
| 1851 | * <?php |
||
| 1852 | * $I->sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST |
||
| 1853 | * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET |
||
| 1854 | * |
||
| 1855 | * ``` |
||
| 1856 | * |
||
| 1857 | * @param $uri |
||
| 1858 | * @param $params |
||
| 1859 | * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() |
||
| 1860 | */ |
||
| 1861 | public function sendAjaxPostRequest($uri, $params = null) { |
||
| 1864 | |||
| 1865 | |||
| 1866 | /** |
||
| 1867 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1868 | * |
||
| 1869 | * If your page triggers an ajax request, you can perform it manually. |
||
| 1870 | * This action sends an ajax request with specified method and params. |
||
| 1871 | * |
||
| 1872 | * Example: |
||
| 1873 | * |
||
| 1874 | * You need to perform an ajax request specifying the HTTP method. |
||
| 1875 | * |
||
| 1876 | * ``` php |
||
| 1877 | * <?php |
||
| 1878 | * $I->sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); |
||
| 1879 | * |
||
| 1880 | * ``` |
||
| 1881 | * |
||
| 1882 | * @param $method |
||
| 1883 | * @param $uri |
||
| 1884 | * @param $params |
||
| 1885 | * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() |
||
| 1886 | */ |
||
| 1887 | public function sendAjaxRequest($method, $uri, $params = null) { |
||
| 1890 | |||
| 1891 | |||
| 1892 | /** |
||
| 1893 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1894 | * |
||
| 1895 | * Finds and returns the text contents of the given element. |
||
| 1896 | * If a fuzzy locator is used, the element is found using CSS, XPath, |
||
| 1897 | * and by matching the full page source by regular expression. |
||
| 1898 | * |
||
| 1899 | * ``` php |
||
| 1900 | * <?php |
||
| 1901 | * $heading = $I->grabTextFrom('h1'); |
||
| 1902 | * $heading = $I->grabTextFrom('descendant-or-self::h1'); |
||
| 1903 | * $value = $I->grabTextFrom('~<input value=(.*?)]~sgi'); // match with a regex |
||
| 1904 | * ?> |
||
| 1905 | * ``` |
||
| 1906 | * |
||
| 1907 | * @param $cssOrXPathOrRegex |
||
| 1908 | * |
||
| 1909 | * @return mixed |
||
| 1910 | * @see \Codeception\Lib\InnerBrowser::grabTextFrom() |
||
| 1911 | */ |
||
| 1912 | public function grabTextFrom($cssOrXPathOrRegex) { |
||
| 1915 | |||
| 1916 | |||
| 1917 | /** |
||
| 1918 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1919 | * |
||
| 1920 | * Grabs the value of the given attribute value from the given element. |
||
| 1921 | * Fails if element is not found. |
||
| 1922 | * |
||
| 1923 | * ``` php |
||
| 1924 | * <?php |
||
| 1925 | * $I->grabAttributeFrom('#tooltip', 'title'); |
||
| 1926 | * ?> |
||
| 1927 | * ``` |
||
| 1928 | * |
||
| 1929 | * |
||
| 1930 | * @param $cssOrXpath |
||
| 1931 | * @param $attribute |
||
| 1932 | * |
||
| 1933 | * @return mixed |
||
| 1934 | * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() |
||
| 1935 | */ |
||
| 1936 | public function grabAttributeFrom($cssOrXpath, $attribute) { |
||
| 1939 | |||
| 1940 | |||
| 1941 | /** |
||
| 1942 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1943 | * |
||
| 1944 | * Grabs either the text content, or attribute values, of nodes |
||
| 1945 | * matched by $cssOrXpath and returns them as an array. |
||
| 1946 | * |
||
| 1947 | * ```html |
||
| 1948 | * <a href="#first">First</a> |
||
| 1949 | * <a href="#second">Second</a> |
||
| 1950 | * <a href="#third">Third</a> |
||
| 1951 | * ``` |
||
| 1952 | * |
||
| 1953 | * ```php |
||
| 1954 | * <?php |
||
| 1955 | * // would return ['First', 'Second', 'Third'] |
||
| 1956 | * $aLinkText = $I->grabMultiple('a'); |
||
| 1957 | * |
||
| 1958 | * // would return ['#first', '#second', '#third'] |
||
| 1959 | * $aLinks = $I->grabMultiple('a', 'href'); |
||
| 1960 | * ?> |
||
| 1961 | * ``` |
||
| 1962 | * |
||
| 1963 | * @param $cssOrXpath |
||
| 1964 | * @param $attribute |
||
| 1965 | * @return string[] |
||
| 1966 | * @see \Codeception\Lib\InnerBrowser::grabMultiple() |
||
| 1967 | */ |
||
| 1968 | public function grabMultiple($cssOrXpath, $attribute = null) { |
||
| 1971 | |||
| 1972 | |||
| 1973 | /** |
||
| 1974 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1975 | * |
||
| 1976 | * @param $field |
||
| 1977 | * |
||
| 1978 | * @return array|mixed|null|string |
||
| 1979 | * @see \Codeception\Lib\InnerBrowser::grabValueFrom() |
||
| 1980 | */ |
||
| 1981 | public function grabValueFrom($field) { |
||
| 1984 | |||
| 1985 | |||
| 1986 | /** |
||
| 1987 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 1988 | * |
||
| 1989 | * Sets a cookie with the given name and value. |
||
| 1990 | * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument. |
||
| 1991 | * |
||
| 1992 | * ``` php |
||
| 1993 | * <?php |
||
| 1994 | * $I->setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); |
||
| 1995 | * ?> |
||
| 1996 | * ``` |
||
| 1997 | * |
||
| 1998 | * @param $name |
||
| 1999 | * @param $val |
||
| 2000 | * @param array $params |
||
| 2001 | * |
||
| 2002 | * @return mixed |
||
| 2003 | * @see \Codeception\Lib\InnerBrowser::setCookie() |
||
| 2004 | */ |
||
| 2005 | public function setCookie($name, $val, $params = null) { |
||
| 2008 | |||
| 2009 | |||
| 2010 | /** |
||
| 2011 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2012 | * |
||
| 2013 | * Grabs a cookie value. |
||
| 2014 | * You can set additional cookie params like `domain`, `path` in array passed as last argument. |
||
| 2015 | * |
||
| 2016 | * @param $cookie |
||
| 2017 | * |
||
| 2018 | * @param array $params |
||
| 2019 | * @return mixed |
||
| 2020 | * @see \Codeception\Lib\InnerBrowser::grabCookie() |
||
| 2021 | */ |
||
| 2022 | public function grabCookie($cookie, $params = null) { |
||
| 2025 | |||
| 2026 | |||
| 2027 | /** |
||
| 2028 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2029 | * |
||
| 2030 | * Grabs current page source code. |
||
| 2031 | * |
||
| 2032 | * @throws ModuleException if no page was opened. |
||
| 2033 | * |
||
| 2034 | * @return string Current page source code. |
||
| 2035 | * @see \Codeception\Lib\InnerBrowser::grabPageSource() |
||
| 2036 | */ |
||
| 2037 | public function grabPageSource() { |
||
| 2040 | |||
| 2041 | |||
| 2042 | /** |
||
| 2043 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2044 | * |
||
| 2045 | * Checks that a cookie with the given name is set. |
||
| 2046 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. |
||
| 2047 | * |
||
| 2048 | * ``` php |
||
| 2049 | * <?php |
||
| 2050 | * $I->seeCookie('PHPSESSID'); |
||
| 2051 | * ?> |
||
| 2052 | * ``` |
||
| 2053 | * |
||
| 2054 | * @param $cookie |
||
| 2055 | * @param array $params |
||
| 2056 | * @return mixed |
||
| 2057 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2058 | * @see \Codeception\Lib\InnerBrowser::seeCookie() |
||
| 2059 | */ |
||
| 2060 | public function canSeeCookie($cookie, $params = null) { |
||
| 2063 | /** |
||
| 2064 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2065 | * |
||
| 2066 | * Checks that a cookie with the given name is set. |
||
| 2067 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. |
||
| 2068 | * |
||
| 2069 | * ``` php |
||
| 2070 | * <?php |
||
| 2071 | * $I->seeCookie('PHPSESSID'); |
||
| 2072 | * ?> |
||
| 2073 | * ``` |
||
| 2074 | * |
||
| 2075 | * @param $cookie |
||
| 2076 | * @param array $params |
||
| 2077 | * @return mixed |
||
| 2078 | * @see \Codeception\Lib\InnerBrowser::seeCookie() |
||
| 2079 | */ |
||
| 2080 | public function seeCookie($cookie, $params = null) { |
||
| 2083 | |||
| 2084 | |||
| 2085 | /** |
||
| 2086 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2087 | * |
||
| 2088 | * Checks that there isn't a cookie with the given name. |
||
| 2089 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. |
||
| 2090 | * |
||
| 2091 | * @param $cookie |
||
| 2092 | * |
||
| 2093 | * @param array $params |
||
| 2094 | * @return mixed |
||
| 2095 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2096 | * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() |
||
| 2097 | */ |
||
| 2098 | public function cantSeeCookie($cookie, $params = null) { |
||
| 2101 | /** |
||
| 2102 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2103 | * |
||
| 2104 | * Checks that there isn't a cookie with the given name. |
||
| 2105 | * You can set additional cookie params like `domain`, `path` as array passed in last argument. |
||
| 2106 | * |
||
| 2107 | * @param $cookie |
||
| 2108 | * |
||
| 2109 | * @param array $params |
||
| 2110 | * @return mixed |
||
| 2111 | * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() |
||
| 2112 | */ |
||
| 2113 | public function dontSeeCookie($cookie, $params = null) { |
||
| 2116 | |||
| 2117 | |||
| 2118 | /** |
||
| 2119 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2120 | * |
||
| 2121 | * Unsets cookie with the given name. |
||
| 2122 | * You can set additional cookie params like `domain`, `path` in array passed as last argument. |
||
| 2123 | * |
||
| 2124 | * @param $cookie |
||
| 2125 | * |
||
| 2126 | * @param array $params |
||
| 2127 | * @return mixed |
||
| 2128 | * @see \Codeception\Lib\InnerBrowser::resetCookie() |
||
| 2129 | */ |
||
| 2130 | public function resetCookie($name, $params = null) { |
||
| 2133 | |||
| 2134 | |||
| 2135 | /** |
||
| 2136 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2137 | * |
||
| 2138 | * Checks that the given element exists on the page and is visible. |
||
| 2139 | * You can also specify expected attributes of this element. |
||
| 2140 | * |
||
| 2141 | * ``` php |
||
| 2142 | * <?php |
||
| 2143 | * $I->seeElement('.error'); |
||
| 2144 | * $I->seeElement('//form/input[1]'); |
||
| 2145 | * $I->seeElement('input', ['name' => 'login']); |
||
| 2146 | * $I->seeElement('input', ['value' => '123456']); |
||
| 2147 | * |
||
| 2148 | * // strict locator in first arg, attributes in second |
||
| 2149 | * $I->seeElement(['css' => 'form input'], ['name' => 'login']); |
||
| 2150 | * ?> |
||
| 2151 | * ``` |
||
| 2152 | * |
||
| 2153 | * @param $selector |
||
| 2154 | * @param array $attributes |
||
| 2155 | * @return |
||
| 2156 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2157 | * @see \Codeception\Lib\InnerBrowser::seeElement() |
||
| 2158 | */ |
||
| 2159 | public function canSeeElement($selector, $attributes = null) { |
||
| 2162 | /** |
||
| 2163 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2164 | * |
||
| 2165 | * Checks that the given element exists on the page and is visible. |
||
| 2166 | * You can also specify expected attributes of this element. |
||
| 2167 | * |
||
| 2168 | * ``` php |
||
| 2169 | * <?php |
||
| 2170 | * $I->seeElement('.error'); |
||
| 2171 | * $I->seeElement('//form/input[1]'); |
||
| 2172 | * $I->seeElement('input', ['name' => 'login']); |
||
| 2173 | * $I->seeElement('input', ['value' => '123456']); |
||
| 2174 | * |
||
| 2175 | * // strict locator in first arg, attributes in second |
||
| 2176 | * $I->seeElement(['css' => 'form input'], ['name' => 'login']); |
||
| 2177 | * ?> |
||
| 2178 | * ``` |
||
| 2179 | * |
||
| 2180 | * @param $selector |
||
| 2181 | * @param array $attributes |
||
| 2182 | * @return |
||
| 2183 | * @see \Codeception\Lib\InnerBrowser::seeElement() |
||
| 2184 | */ |
||
| 2185 | public function seeElement($selector, $attributes = null) { |
||
| 2188 | |||
| 2189 | |||
| 2190 | /** |
||
| 2191 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2192 | * |
||
| 2193 | * Checks that the given element is invisible or not present on the page. |
||
| 2194 | * You can also specify expected attributes of this element. |
||
| 2195 | * |
||
| 2196 | * ``` php |
||
| 2197 | * <?php |
||
| 2198 | * $I->dontSeeElement('.error'); |
||
| 2199 | * $I->dontSeeElement('//form/input[1]'); |
||
| 2200 | * $I->dontSeeElement('input', ['name' => 'login']); |
||
| 2201 | * $I->dontSeeElement('input', ['value' => '123456']); |
||
| 2202 | * ?> |
||
| 2203 | * ``` |
||
| 2204 | * |
||
| 2205 | * @param $selector |
||
| 2206 | * @param array $attributes |
||
| 2207 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2208 | * @see \Codeception\Lib\InnerBrowser::dontSeeElement() |
||
| 2209 | */ |
||
| 2210 | public function cantSeeElement($selector, $attributes = null) { |
||
| 2213 | /** |
||
| 2214 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2215 | * |
||
| 2216 | * Checks that the given element is invisible or not present on the page. |
||
| 2217 | * You can also specify expected attributes of this element. |
||
| 2218 | * |
||
| 2219 | * ``` php |
||
| 2220 | * <?php |
||
| 2221 | * $I->dontSeeElement('.error'); |
||
| 2222 | * $I->dontSeeElement('//form/input[1]'); |
||
| 2223 | * $I->dontSeeElement('input', ['name' => 'login']); |
||
| 2224 | * $I->dontSeeElement('input', ['value' => '123456']); |
||
| 2225 | * ?> |
||
| 2226 | * ``` |
||
| 2227 | * |
||
| 2228 | * @param $selector |
||
| 2229 | * @param array $attributes |
||
| 2230 | * @see \Codeception\Lib\InnerBrowser::dontSeeElement() |
||
| 2231 | */ |
||
| 2232 | public function dontSeeElement($selector, $attributes = null) { |
||
| 2235 | |||
| 2236 | |||
| 2237 | /** |
||
| 2238 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2239 | * |
||
| 2240 | * Checks that there are a certain number of elements matched by the given locator on the page. |
||
| 2241 | * |
||
| 2242 | * ``` php |
||
| 2243 | * <?php |
||
| 2244 | * $I->seeNumberOfElements('tr', 10); |
||
| 2245 | * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements |
||
| 2246 | * ?> |
||
| 2247 | * ``` |
||
| 2248 | * @param $selector |
||
| 2249 | * @param mixed $expected : |
||
| 2250 | * - string: strict number |
||
| 2251 | * - array: range of numbers [0,10] |
||
| 2252 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2253 | * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() |
||
| 2254 | */ |
||
| 2255 | public function canSeeNumberOfElements($selector, $expected) { |
||
| 2258 | /** |
||
| 2259 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2260 | * |
||
| 2261 | * Checks that there are a certain number of elements matched by the given locator on the page. |
||
| 2262 | * |
||
| 2263 | * ``` php |
||
| 2264 | * <?php |
||
| 2265 | * $I->seeNumberOfElements('tr', 10); |
||
| 2266 | * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements |
||
| 2267 | * ?> |
||
| 2268 | * ``` |
||
| 2269 | * @param $selector |
||
| 2270 | * @param mixed $expected : |
||
| 2271 | * - string: strict number |
||
| 2272 | * - array: range of numbers [0,10] |
||
| 2273 | * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() |
||
| 2274 | */ |
||
| 2275 | public function seeNumberOfElements($selector, $expected) { |
||
| 2278 | |||
| 2279 | |||
| 2280 | /** |
||
| 2281 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2282 | * |
||
| 2283 | * Checks that the given option is selected. |
||
| 2284 | * |
||
| 2285 | * ``` php |
||
| 2286 | * <?php |
||
| 2287 | * $I->seeOptionIsSelected('#form input[name=payment]', 'Visa'); |
||
| 2288 | * ?> |
||
| 2289 | * ``` |
||
| 2290 | * |
||
| 2291 | * @param $selector |
||
| 2292 | * @param $optionText |
||
| 2293 | * |
||
| 2294 | * @return mixed |
||
| 2295 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2296 | * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() |
||
| 2297 | */ |
||
| 2298 | public function canSeeOptionIsSelected($selector, $optionText) { |
||
| 2301 | /** |
||
| 2302 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2303 | * |
||
| 2304 | * Checks that the given option is selected. |
||
| 2305 | * |
||
| 2306 | * ``` php |
||
| 2307 | * <?php |
||
| 2308 | * $I->seeOptionIsSelected('#form input[name=payment]', 'Visa'); |
||
| 2309 | * ?> |
||
| 2310 | * ``` |
||
| 2311 | * |
||
| 2312 | * @param $selector |
||
| 2313 | * @param $optionText |
||
| 2314 | * |
||
| 2315 | * @return mixed |
||
| 2316 | * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() |
||
| 2317 | */ |
||
| 2318 | public function seeOptionIsSelected($selector, $optionText) { |
||
| 2321 | |||
| 2322 | |||
| 2323 | /** |
||
| 2324 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2325 | * |
||
| 2326 | * Checks that the given option is not selected. |
||
| 2327 | * |
||
| 2328 | * ``` php |
||
| 2329 | * <?php |
||
| 2330 | * $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); |
||
| 2331 | * ?> |
||
| 2332 | * ``` |
||
| 2333 | * |
||
| 2334 | * @param $selector |
||
| 2335 | * @param $optionText |
||
| 2336 | * |
||
| 2337 | * @return mixed |
||
| 2338 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2339 | * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() |
||
| 2340 | */ |
||
| 2341 | public function cantSeeOptionIsSelected($selector, $optionText) { |
||
| 2344 | /** |
||
| 2345 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2346 | * |
||
| 2347 | * Checks that the given option is not selected. |
||
| 2348 | * |
||
| 2349 | * ``` php |
||
| 2350 | * <?php |
||
| 2351 | * $I->dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); |
||
| 2352 | * ?> |
||
| 2353 | * ``` |
||
| 2354 | * |
||
| 2355 | * @param $selector |
||
| 2356 | * @param $optionText |
||
| 2357 | * |
||
| 2358 | * @return mixed |
||
| 2359 | * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() |
||
| 2360 | */ |
||
| 2361 | public function dontSeeOptionIsSelected($selector, $optionText) { |
||
| 2364 | |||
| 2365 | |||
| 2366 | /** |
||
| 2367 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2368 | * |
||
| 2369 | * Asserts that current page has 404 response status code. |
||
| 2370 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2371 | * @see \Codeception\Lib\InnerBrowser::seePageNotFound() |
||
| 2372 | */ |
||
| 2373 | public function canSeePageNotFound() { |
||
| 2376 | /** |
||
| 2377 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2378 | * |
||
| 2379 | * Asserts that current page has 404 response status code. |
||
| 2380 | * @see \Codeception\Lib\InnerBrowser::seePageNotFound() |
||
| 2381 | */ |
||
| 2382 | public function seePageNotFound() { |
||
| 2385 | |||
| 2386 | |||
| 2387 | /** |
||
| 2388 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2389 | * |
||
| 2390 | * Checks that response code is equal to value provided. |
||
| 2391 | * |
||
| 2392 | * ```php |
||
| 2393 | * <?php |
||
| 2394 | * $I->seeResponseCodeIs(200); |
||
| 2395 | * |
||
| 2396 | * // recommended \Codeception\Util\HttpCode |
||
| 2397 | * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); |
||
| 2398 | * ``` |
||
| 2399 | * |
||
| 2400 | * @param $code |
||
| 2401 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2402 | * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() |
||
| 2403 | */ |
||
| 2404 | public function canSeeResponseCodeIs($code) { |
||
| 2407 | /** |
||
| 2408 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2409 | * |
||
| 2410 | * Checks that response code is equal to value provided. |
||
| 2411 | * |
||
| 2412 | * ```php |
||
| 2413 | * <?php |
||
| 2414 | * $I->seeResponseCodeIs(200); |
||
| 2415 | * |
||
| 2416 | * // recommended \Codeception\Util\HttpCode |
||
| 2417 | * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); |
||
| 2418 | * ``` |
||
| 2419 | * |
||
| 2420 | * @param $code |
||
| 2421 | * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() |
||
| 2422 | */ |
||
| 2423 | public function seeResponseCodeIs($code) { |
||
| 2426 | |||
| 2427 | |||
| 2428 | /** |
||
| 2429 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2430 | * |
||
| 2431 | * Checks that response code is equal to value provided. |
||
| 2432 | * |
||
| 2433 | * ```php |
||
| 2434 | * <?php |
||
| 2435 | * $I->dontSeeResponseCodeIs(200); |
||
| 2436 | * |
||
| 2437 | * // recommended \Codeception\Util\HttpCode |
||
| 2438 | * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK); |
||
| 2439 | * ``` |
||
| 2440 | * @param $code |
||
| 2441 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2442 | * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs() |
||
| 2443 | */ |
||
| 2444 | public function cantSeeResponseCodeIs($code) { |
||
| 2447 | /** |
||
| 2448 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2449 | * |
||
| 2450 | * Checks that response code is equal to value provided. |
||
| 2451 | * |
||
| 2452 | * ```php |
||
| 2453 | * <?php |
||
| 2454 | * $I->dontSeeResponseCodeIs(200); |
||
| 2455 | * |
||
| 2456 | * // recommended \Codeception\Util\HttpCode |
||
| 2457 | * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK); |
||
| 2458 | * ``` |
||
| 2459 | * @param $code |
||
| 2460 | * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs() |
||
| 2461 | */ |
||
| 2462 | public function dontSeeResponseCodeIs($code) { |
||
| 2465 | |||
| 2466 | |||
| 2467 | /** |
||
| 2468 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2469 | * |
||
| 2470 | * Checks that the page title contains the given string. |
||
| 2471 | * |
||
| 2472 | * ``` php |
||
| 2473 | * <?php |
||
| 2474 | * $I->seeInTitle('Blog - Post #1'); |
||
| 2475 | * ?> |
||
| 2476 | * ``` |
||
| 2477 | * |
||
| 2478 | * @param $title |
||
| 2479 | * |
||
| 2480 | * @return mixed |
||
| 2481 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2482 | * @see \Codeception\Lib\InnerBrowser::seeInTitle() |
||
| 2483 | */ |
||
| 2484 | public function canSeeInTitle($title) { |
||
| 2487 | /** |
||
| 2488 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2489 | * |
||
| 2490 | * Checks that the page title contains the given string. |
||
| 2491 | * |
||
| 2492 | * ``` php |
||
| 2493 | * <?php |
||
| 2494 | * $I->seeInTitle('Blog - Post #1'); |
||
| 2495 | * ?> |
||
| 2496 | * ``` |
||
| 2497 | * |
||
| 2498 | * @param $title |
||
| 2499 | * |
||
| 2500 | * @return mixed |
||
| 2501 | * @see \Codeception\Lib\InnerBrowser::seeInTitle() |
||
| 2502 | */ |
||
| 2503 | public function seeInTitle($title) { |
||
| 2506 | |||
| 2507 | |||
| 2508 | /** |
||
| 2509 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2510 | * |
||
| 2511 | * Checks that the page title does not contain the given string. |
||
| 2512 | * |
||
| 2513 | * @param $title |
||
| 2514 | * |
||
| 2515 | * @return mixed |
||
| 2516 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2517 | * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() |
||
| 2518 | */ |
||
| 2519 | public function cantSeeInTitle($title) { |
||
| 2522 | /** |
||
| 2523 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2524 | * |
||
| 2525 | * Checks that the page title does not contain the given string. |
||
| 2526 | * |
||
| 2527 | * @param $title |
||
| 2528 | * |
||
| 2529 | * @return mixed |
||
| 2530 | * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() |
||
| 2531 | */ |
||
| 2532 | public function dontSeeInTitle($title) { |
||
| 2535 | |||
| 2536 | |||
| 2537 | /** |
||
| 2538 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2539 | * |
||
| 2540 | * Switch to iframe or frame on the page. |
||
| 2541 | * |
||
| 2542 | * Example: |
||
| 2543 | * ``` html |
||
| 2544 | * <iframe name="another_frame" src="http://example.com"> |
||
| 2545 | * ``` |
||
| 2546 | * |
||
| 2547 | * ``` php |
||
| 2548 | * <?php |
||
| 2549 | * # switch to iframe |
||
| 2550 | * $I->switchToIframe("another_frame"); |
||
| 2551 | * ``` |
||
| 2552 | * |
||
| 2553 | * @param string $name |
||
| 2554 | * @see \Codeception\Lib\InnerBrowser::switchToIframe() |
||
| 2555 | */ |
||
| 2556 | public function switchToIframe($name) { |
||
| 2559 | |||
| 2560 | |||
| 2561 | /** |
||
| 2562 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2563 | * |
||
| 2564 | * Moves back in history. |
||
| 2565 | * |
||
| 2566 | * @param int $numberOfSteps (default value 1) |
||
| 2567 | * @see \Codeception\Lib\InnerBrowser::moveBack() |
||
| 2568 | */ |
||
| 2569 | public function moveBack($numberOfSteps = null) { |
||
| 2572 | |||
| 2573 | |||
| 2574 | /** |
||
| 2575 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2576 | * |
||
| 2577 | * Change currently running application the module params |
||
| 2578 | * @param array $params new params value |
||
| 2579 | * @param string|null $moduleId module id for change configuration. if null, use Fnctional::$_moduleId |
||
| 2580 | * @see \Helper\Functional::changeModuleParams() |
||
| 2581 | */ |
||
| 2582 | public function changeModuleParams($params, $moduleId = null) { |
||
| 2585 | |||
| 2586 | |||
| 2587 | /** |
||
| 2588 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2589 | * |
||
| 2590 | * |
||
| 2591 | * @see \Codeception\Module\Db::isPopulated() |
||
| 2592 | */ |
||
| 2593 | public function isPopulated() { |
||
| 2596 | |||
| 2597 | |||
| 2598 | /** |
||
| 2599 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2600 | * |
||
| 2601 | * Inserts an SQL record into a database. This record will be erased after the test. |
||
| 2602 | * |
||
| 2603 | * ```php |
||
| 2604 | * <?php |
||
| 2605 | * $I->haveInDatabase('users', array('name' => 'miles', 'email' => '[email protected]')); |
||
| 2606 | * ?> |
||
| 2607 | * ``` |
||
| 2608 | * |
||
| 2609 | * @param string $table |
||
| 2610 | * @param array $data |
||
| 2611 | * |
||
| 2612 | * @return integer $id |
||
| 2613 | * @see \Codeception\Module\Db::haveInDatabase() |
||
| 2614 | */ |
||
| 2615 | public function haveInDatabase($table, $data) { |
||
| 2618 | |||
| 2619 | |||
| 2620 | /** |
||
| 2621 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2622 | * |
||
| 2623 | * Asserts that a row with the given column values exists. |
||
| 2624 | * Provide table name and column values. |
||
| 2625 | * |
||
| 2626 | * ``` php |
||
| 2627 | * <?php |
||
| 2628 | * $I->seeInDatabase('users', array('name' => 'Davert', 'email' => '[email protected]')); |
||
| 2629 | * ``` |
||
| 2630 | * Fails if no such user found. |
||
| 2631 | * |
||
| 2632 | * @param string $table |
||
| 2633 | * @param array $criteria |
||
| 2634 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2635 | * @see \Codeception\Module\Db::seeInDatabase() |
||
| 2636 | */ |
||
| 2637 | public function canSeeInDatabase($table, $criteria = null) { |
||
| 2640 | /** |
||
| 2641 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2642 | * |
||
| 2643 | * Asserts that a row with the given column values exists. |
||
| 2644 | * Provide table name and column values. |
||
| 2645 | * |
||
| 2646 | * ``` php |
||
| 2647 | * <?php |
||
| 2648 | * $I->seeInDatabase('users', array('name' => 'Davert', 'email' => '[email protected]')); |
||
| 2649 | * ``` |
||
| 2650 | * Fails if no such user found. |
||
| 2651 | * |
||
| 2652 | * @param string $table |
||
| 2653 | * @param array $criteria |
||
| 2654 | * @see \Codeception\Module\Db::seeInDatabase() |
||
| 2655 | */ |
||
| 2656 | public function seeInDatabase($table, $criteria = null) { |
||
| 2659 | |||
| 2660 | |||
| 2661 | /** |
||
| 2662 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2663 | * |
||
| 2664 | * Asserts that the given number of records were found in the database. |
||
| 2665 | * |
||
| 2666 | * ```php |
||
| 2667 | * <?php |
||
| 2668 | * $I->seeNumRecords(1, 'users', ['name' => 'davert']) |
||
| 2669 | * ?> |
||
| 2670 | * ``` |
||
| 2671 | * |
||
| 2672 | * @param int $expectedNumber Expected number |
||
| 2673 | * @param string $table Table name |
||
| 2674 | * @param array $criteria Search criteria [Optional] |
||
| 2675 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2676 | * @see \Codeception\Module\Db::seeNumRecords() |
||
| 2677 | */ |
||
| 2678 | public function canSeeNumRecords($expectedNumber, $table, $criteria = null) { |
||
| 2681 | /** |
||
| 2682 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2683 | * |
||
| 2684 | * Asserts that the given number of records were found in the database. |
||
| 2685 | * |
||
| 2686 | * ```php |
||
| 2687 | * <?php |
||
| 2688 | * $I->seeNumRecords(1, 'users', ['name' => 'davert']) |
||
| 2689 | * ?> |
||
| 2690 | * ``` |
||
| 2691 | * |
||
| 2692 | * @param int $expectedNumber Expected number |
||
| 2693 | * @param string $table Table name |
||
| 2694 | * @param array $criteria Search criteria [Optional] |
||
| 2695 | * @see \Codeception\Module\Db::seeNumRecords() |
||
| 2696 | */ |
||
| 2697 | public function seeNumRecords($expectedNumber, $table, $criteria = null) { |
||
| 2700 | |||
| 2701 | |||
| 2702 | /** |
||
| 2703 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2704 | * |
||
| 2705 | * Effect is opposite to ->seeInDatabase |
||
| 2706 | * |
||
| 2707 | * Asserts that there is no record with the given column values in a database. |
||
| 2708 | * Provide table name and column values. |
||
| 2709 | * |
||
| 2710 | * ``` php |
||
| 2711 | * <?php |
||
| 2712 | * $I->dontSeeInDatabase('users', array('name' => 'Davert', 'email' => '[email protected]')); |
||
| 2713 | * ``` |
||
| 2714 | * Fails if such user was found. |
||
| 2715 | * |
||
| 2716 | * @param string $table |
||
| 2717 | * @param array $criteria |
||
| 2718 | * Conditional Assertion: Test won't be stopped on fail |
||
| 2719 | * @see \Codeception\Module\Db::dontSeeInDatabase() |
||
| 2720 | */ |
||
| 2721 | public function cantSeeInDatabase($table, $criteria = null) { |
||
| 2724 | /** |
||
| 2725 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2726 | * |
||
| 2727 | * Effect is opposite to ->seeInDatabase |
||
| 2728 | * |
||
| 2729 | * Asserts that there is no record with the given column values in a database. |
||
| 2730 | * Provide table name and column values. |
||
| 2731 | * |
||
| 2732 | * ``` php |
||
| 2733 | * <?php |
||
| 2734 | * $I->dontSeeInDatabase('users', array('name' => 'Davert', 'email' => '[email protected]')); |
||
| 2735 | * ``` |
||
| 2736 | * Fails if such user was found. |
||
| 2737 | * |
||
| 2738 | * @param string $table |
||
| 2739 | * @param array $criteria |
||
| 2740 | * @see \Codeception\Module\Db::dontSeeInDatabase() |
||
| 2741 | */ |
||
| 2742 | public function dontSeeInDatabase($table, $criteria = null) { |
||
| 2745 | |||
| 2746 | |||
| 2747 | /** |
||
| 2748 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2749 | * |
||
| 2750 | * Fetches a single column value from a database. |
||
| 2751 | * Provide table name, desired column and criteria. |
||
| 2752 | * |
||
| 2753 | * ``` php |
||
| 2754 | * <?php |
||
| 2755 | * $mail = $I->grabFromDatabase('users', 'email', array('name' => 'Davert')); |
||
| 2756 | * ``` |
||
| 2757 | * |
||
| 2758 | * @param string $table |
||
| 2759 | * @param string $column |
||
| 2760 | * @param array $criteria |
||
| 2761 | * |
||
| 2762 | * @return mixed |
||
| 2763 | * @see \Codeception\Module\Db::grabFromDatabase() |
||
| 2764 | */ |
||
| 2765 | public function grabFromDatabase($table, $column, $criteria = null) { |
||
| 2768 | |||
| 2769 | |||
| 2770 | /** |
||
| 2771 | * [!] Method is generated. Documentation taken from corresponding module. |
||
| 2772 | * |
||
| 2773 | * Returns the number of rows in a database |
||
| 2774 | * |
||
| 2775 | * @param string $table Table name |
||
| 2776 | * @param array $criteria Search criteria [Optional] |
||
| 2777 | * |
||
| 2778 | * @return int |
||
| 2779 | * @see \Codeception\Module\Db::grabNumRecords() |
||
| 2780 | */ |
||
| 2781 | public function grabNumRecords($table, $criteria = null) { |
||
| 2784 | } |
||
| 2785 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.