| @@ 51-59 (lines=9) @@ | ||
| 48 | * @throws \Exception |
|
| 49 | * If region or button within it cannot be found. |
|
| 50 | */ |
|
| 51 | public function assertRegionButton($button, $region) |
|
| 52 | { |
|
| 53 | $regionObj = $this->getRegion($region); |
|
| 54 | ||
| 55 | $buttonObj = $regionObj->findButton($button); |
|
| 56 | if (empty($buttonObj)) { |
|
| 57 | throw new \Exception(sprintf("The button '%s' was not found in the region '%s' on the page %s", $button, $region, $this->getSession()->getCurrentUrl())); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Asserts that a button does not exists in a region. |
|
| @@ 75-83 (lines=9) @@ | ||
| 72 | * @throws \Exception |
|
| 73 | * If region is not found or the button is found within the region. |
|
| 74 | */ |
|
| 75 | public function assertNotRegionButton($button, $region) |
|
| 76 | { |
|
| 77 | $regionObj = $this->getRegion($region); |
|
| 78 | ||
| 79 | $buttonObj = $regionObj->findButton($button); |
|
| 80 | if (!empty($buttonObj)) { |
|
| 81 | throw new \Exception(sprintf("The button '%s' was found in the region '%s' on the page %s but should not", $button, $region, $this->getSession()->getCurrentUrl())); |
|
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * @Then I( should) see the :tag element in the :region( region) |
|
| @@ 88-96 (lines=9) @@ | ||
| 85 | /** |
|
| 86 | * @Then I( should) see the :tag element in the :region( region) |
|
| 87 | */ |
|
| 88 | public function assertRegionElement($tag, $region) |
|
| 89 | { |
|
| 90 | $regionObj = $this->getRegion($region); |
|
| 91 | $elements = $regionObj->findAll('css', $tag); |
|
| 92 | if (!empty($elements)) { |
|
| 93 | return; |
|
| 94 | } |
|
| 95 | throw new \Exception(sprintf('The element "%s" was not found in the "%s" region on the page %s', $tag, $region, $this->getSession()->getCurrentUrl())); |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * @Then I( should) not see the :tag element in the :region( region) |
|
| @@ 101-108 (lines=8) @@ | ||
| 98 | /** |
|
| 99 | * @Then I( should) not see the :tag element in the :region( region) |
|
| 100 | */ |
|
| 101 | public function assertNotRegionElement($tag, $region) |
|
| 102 | { |
|
| 103 | $regionObj = $this->getRegion($region); |
|
| 104 | $result = $regionObj->findAll('css', $tag); |
|
| 105 | if (!empty($result)) { |
|
| 106 | throw new \Exception(sprintf('The element "%s" was found in the "%s" region on the page %s', $tag, $region, $this->getSession()->getCurrentUrl())); |
|
| 107 | } |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * @Then I( should) not see :text in the :tag element in the :region( region) |
|
| @@ 364-371 (lines=8) @@ | ||
| 361 | * @Then I (should ) see the button :button |
|
| 362 | * @Then I (should ) see the :button button |
|
| 363 | */ |
|
| 364 | public function assertButton($button) |
|
| 365 | { |
|
| 366 | $element = $this->getSession()->getPage(); |
|
| 367 | $buttonObj = $element->findButton($button); |
|
| 368 | if (empty($buttonObj)) { |
|
| 369 | throw new \Exception(sprintf("The button '%s' was not found on the page %s", $button, $this->getSession()->getCurrentUrl())); |
|
| 370 | } |
|
| 371 | } |
|
| 372 | ||
| 373 | /** |
|
| 374 | * @Then I should not see the button :button |
|
| @@ 377-384 (lines=8) @@ | ||
| 374 | * @Then I should not see the button :button |
|
| 375 | * @Then I should not see the :button button |
|
| 376 | */ |
|
| 377 | public function assertNotButton($button) |
|
| 378 | { |
|
| 379 | $element = $this->getSession()->getPage(); |
|
| 380 | $buttonObj = $element->findButton($button); |
|
| 381 | if (!empty($buttonObj)) { |
|
| 382 | throw new \Exception(sprintf("The button '%s' was found on the page %s", $button, $this->getSession()->getCurrentUrl())); |
|
| 383 | } |
|
| 384 | } |
|
| 385 | ||
| 386 | /** |
|
| 387 | * @When I follow/click :link in the :region( region) |
|
| @@ 392-402 (lines=11) @@ | ||
| 389 | * @throws \Exception |
|
| 390 | * If region or link within it cannot be found. |
|
| 391 | */ |
|
| 392 | public function assertRegionLinkFollow($link, $region) |
|
| 393 | { |
|
| 394 | $regionObj = $this->getRegion($region); |
|
| 395 | ||
| 396 | // Find the link within the region |
|
| 397 | $linkObj = $regionObj->findLink($link); |
|
| 398 | if (empty($linkObj)) { |
|
| 399 | throw new \Exception(sprintf('The link "%s" was not found in the region "%s" on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 400 | } |
|
| 401 | $linkObj->click(); |
|
| 402 | } |
|
| 403 | ||
| 404 | /** |
|
| 405 | * Checks, if a button with id|name|title|alt|value exists or not and pressess the same |
|
| @@ 417-426 (lines=10) @@ | ||
| 414 | * @throws \Exception |
|
| 415 | * If region or button within it cannot be found. |
|
| 416 | */ |
|
| 417 | public function assertRegionPressButton($button, $region) |
|
| 418 | { |
|
| 419 | $regionObj = $this->getRegion($region); |
|
| 420 | ||
| 421 | $buttonObj = $regionObj->findButton($button); |
|
| 422 | if (empty($buttonObj)) { |
|
| 423 | throw new \Exception(sprintf("The button '%s' was not found in the region '%s' on the page %s", $button, $region, $this->getSession()->getCurrentUrl())); |
|
| 424 | } |
|
| 425 | $regionObj->pressButton($button); |
|
| 426 | } |
|
| 427 | ||
| 428 | /** |
|
| 429 | * Fills in a form field with id|name|title|alt|value in the specified region. |
|
| @@ 478-486 (lines=9) @@ | ||
| 475 | * @throws \Exception |
|
| 476 | * If region or link within it cannot be found. |
|
| 477 | */ |
|
| 478 | public function assertLinkRegion($link, $region) |
|
| 479 | { |
|
| 480 | $regionObj = $this->getRegion($region); |
|
| 481 | ||
| 482 | $result = $regionObj->findLink($link); |
|
| 483 | if (empty($result)) { |
|
| 484 | throw new \Exception(sprintf('No link to "%s" in the "%s" region on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 485 | } |
|
| 486 | } |
|
| 487 | ||
| 488 | /** |
|
| 489 | * @Then I should not see the link :link in the :region( region) |
|
| @@ 494-502 (lines=9) @@ | ||
| 491 | * @throws \Exception |
|
| 492 | * If region or link within it cannot be found. |
|
| 493 | */ |
|
| 494 | public function assertNotLinkRegion($link, $region) |
|
| 495 | { |
|
| 496 | $regionObj = $this->getRegion($region); |
|
| 497 | ||
| 498 | $result = $regionObj->findLink($link); |
|
| 499 | if (!empty($result)) { |
|
| 500 | throw new \Exception(sprintf('Link to "%s" in the "%s" region on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 501 | } |
|
| 502 | } |
|
| 503 | ||
| 504 | /** |
|
| 505 | * @Then I should see( the text) :text in the :region( region) |
|
| @@ 510-519 (lines=10) @@ | ||
| 507 | * @throws \Exception |
|
| 508 | * If region or text within it cannot be found. |
|
| 509 | */ |
|
| 510 | public function assertRegionText($text, $region) |
|
| 511 | { |
|
| 512 | $regionObj = $this->getRegion($region); |
|
| 513 | ||
| 514 | // Find the text within the region |
|
| 515 | $regionText = $regionObj->getText(); |
|
| 516 | if (strpos($regionText, $text) === false) { |
|
| 517 | throw new \Exception(sprintf("The text '%s' was not found in the region '%s' on the page %s", $text, $region, $this->getSession()->getCurrentUrl())); |
|
| 518 | } |
|
| 519 | } |
|
| 520 | ||
| 521 | /** |
|
| 522 | * @Then I should not see( the text) :text in the :region( region) |
|
| @@ 527-536 (lines=10) @@ | ||
| 524 | * @throws \Exception |
|
| 525 | * If region or text within it cannot be found. |
|
| 526 | */ |
|
| 527 | public function assertNotRegionText($text, $region) |
|
| 528 | { |
|
| 529 | $regionObj = $this->getRegion($region); |
|
| 530 | ||
| 531 | // Find the text within the region. |
|
| 532 | $regionText = $regionObj->getText(); |
|
| 533 | if (strpos($regionText, $text) !== false) { |
|
| 534 | throw new \Exception(sprintf('The text "%s" was found in the region "%s" on the page %s', $text, $region, $this->getSession()->getCurrentUrl())); |
|
| 535 | } |
|
| 536 | } |
|
| 537 | ||
| 538 | /** |
|
| 539 | * @Then I (should )see the text :text |
|