| @@ 51-58 (lines=8) @@ | ||
| 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 | /** |
|
| @@ 64-71 (lines=8) @@ | ||
| 61 | /** |
|
| 62 | * @Then I( should) see the :tag element in the :region( region) |
|
| 63 | */ |
|
| 64 | public function assertRegionElement($tag, $region) |
|
| 65 | { |
|
| 66 | $regionObj = $this->getRegion($region); |
|
| 67 | $elements = $regionObj->findAll('css', $tag); |
|
| 68 | if (!empty($elements)) { |
|
| 69 | return; |
|
| 70 | } |
|
| 71 | throw new \Exception(sprintf('The element "%s" was not found in the "%s" region on the page %s', $tag, $region, $this->getSession()->getCurrentUrl())); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| @@ 77-83 (lines=7) @@ | ||
| 74 | /** |
|
| 75 | * @Then I( should) not see the :tag element in the :region( region) |
|
| 76 | */ |
|
| 77 | public function assertNotRegionElement($tag, $region) |
|
| 78 | { |
|
| 79 | $regionObj = $this->getRegion($region); |
|
| 80 | $result = $regionObj->findAll('css', $tag); |
|
| 81 | if (!empty($result)) { |
|
| 82 | throw new \Exception(sprintf('The element "%s" was found in the "%s" region on the page %s', $tag, $region, $this->getSession()->getCurrentUrl())); |
|
| 83 | } |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| @@ 344-350 (lines=7) @@ | ||
| 341 | * @Then I (should ) see the button :button |
|
| 342 | * @Then I (should ) see the :button button |
|
| 343 | */ |
|
| 344 | public function assertButton($button) |
|
| 345 | { |
|
| 346 | $element = $this->getSession()->getPage(); |
|
| 347 | $buttonObj = $element->findButton($button); |
|
| 348 | if (empty($buttonObj)) { |
|
| 349 | throw new \Exception(sprintf("The button '%s' was not found on the page %s", $button, $this->getSession()->getCurrentUrl())); |
|
| 350 | } |
|
| 351 | } |
|
| 352 | ||
| 353 | /** |
|
| @@ 357-363 (lines=7) @@ | ||
| 354 | * @Then I should not see the button :button |
|
| 355 | * @Then I should not see the :button button |
|
| 356 | */ |
|
| 357 | public function assertNotButton($button) |
|
| 358 | { |
|
| 359 | $element = $this->getSession()->getPage(); |
|
| 360 | $buttonObj = $element->findButton($button); |
|
| 361 | if (!empty($buttonObj)) { |
|
| 362 | throw new \Exception(sprintf("The button '%s' was found on the page %s", $button, $this->getSession()->getCurrentUrl())); |
|
| 363 | } |
|
| 364 | } |
|
| 365 | ||
| 366 | /** |
|
| @@ 372-381 (lines=10) @@ | ||
| 369 | * @throws \Exception |
|
| 370 | * If region or link within it cannot be found. |
|
| 371 | */ |
|
| 372 | public function assertRegionLinkFollow($link, $region) |
|
| 373 | { |
|
| 374 | $regionObj = $this->getRegion($region); |
|
| 375 | ||
| 376 | // Find the link within the region |
|
| 377 | $linkObj = $regionObj->findLink($link); |
|
| 378 | if (empty($linkObj)) { |
|
| 379 | throw new \Exception(sprintf('The link "%s" was not found in the region "%s" on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 380 | } |
|
| 381 | $linkObj->click(); |
|
| 382 | } |
|
| 383 | ||
| 384 | /** |
|
| @@ 397-405 (lines=9) @@ | ||
| 394 | * @throws \Exception |
|
| 395 | * If region or button within it cannot be found. |
|
| 396 | */ |
|
| 397 | public function assertRegionPressButton($button, $region) |
|
| 398 | { |
|
| 399 | $regionObj = $this->getRegion($region); |
|
| 400 | ||
| 401 | $buttonObj = $regionObj->findButton($button); |
|
| 402 | if (empty($buttonObj)) { |
|
| 403 | throw new \Exception(sprintf("The button '%s' was not found in the region '%s' on the page %s", $button, $region, $this->getSession()->getCurrentUrl())); |
|
| 404 | } |
|
| 405 | $regionObj->pressButton($button); |
|
| 406 | } |
|
| 407 | ||
| 408 | /** |
|
| @@ 458-465 (lines=8) @@ | ||
| 455 | * @throws \Exception |
|
| 456 | * If region or link within it cannot be found. |
|
| 457 | */ |
|
| 458 | public function assertLinkRegion($link, $region) |
|
| 459 | { |
|
| 460 | $regionObj = $this->getRegion($region); |
|
| 461 | ||
| 462 | $result = $regionObj->findLink($link); |
|
| 463 | if (empty($result)) { |
|
| 464 | throw new \Exception(sprintf('No link to "%s" in the "%s" region on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 465 | } |
|
| 466 | } |
|
| 467 | ||
| 468 | /** |
|
| @@ 474-481 (lines=8) @@ | ||
| 471 | * @throws \Exception |
|
| 472 | * If region or link within it cannot be found. |
|
| 473 | */ |
|
| 474 | public function assertNotLinkRegion($link, $region) |
|
| 475 | { |
|
| 476 | $regionObj = $this->getRegion($region); |
|
| 477 | ||
| 478 | $result = $regionObj->findLink($link); |
|
| 479 | if (!empty($result)) { |
|
| 480 | throw new \Exception(sprintf('Link to "%s" in the "%s" region on the page %s', $link, $region, $this->getSession()->getCurrentUrl())); |
|
| 481 | } |
|
| 482 | } |
|
| 483 | ||
| 484 | /** |
|
| @@ 490-498 (lines=9) @@ | ||
| 487 | * @throws \Exception |
|
| 488 | * If region or text within it cannot be found. |
|
| 489 | */ |
|
| 490 | public function assertRegionText($text, $region) |
|
| 491 | { |
|
| 492 | $regionObj = $this->getRegion($region); |
|
| 493 | ||
| 494 | // Find the text within the region |
|
| 495 | $regionText = $regionObj->getText(); |
|
| 496 | if (strpos($regionText, $text) === false) { |
|
| 497 | throw new \Exception(sprintf("The text '%s' was not found in the region '%s' on the page %s", $text, $region, $this->getSession()->getCurrentUrl())); |
|
| 498 | } |
|
| 499 | } |
|
| 500 | ||
| 501 | /** |
|
| @@ 507-515 (lines=9) @@ | ||
| 504 | * @throws \Exception |
|
| 505 | * If region or text within it cannot be found. |
|
| 506 | */ |
|
| 507 | public function assertNotRegionText($text, $region) |
|
| 508 | { |
|
| 509 | $regionObj = $this->getRegion($region); |
|
| 510 | ||
| 511 | // Find the text within the region. |
|
| 512 | $regionText = $regionObj->getText(); |
|
| 513 | if (strpos($regionText, $text) !== false) { |
|
| 514 | throw new \Exception(sprintf('The text "%s" was found in the region "%s" on the page %s', $text, $region, $this->getSession()->getCurrentUrl())); |
|
| 515 | } |
|
| 516 | } |
|
| 517 | ||
| 518 | /** |
|
| @@ 182-188 (lines=7) @@ | ||
| 179 | * |
|
| 180 | * @Then I should see (the text ):text in the :rowText row |
|
| 181 | */ |
|
| 182 | public function assertTextInTableRow($text, $rowText) |
|
| 183 | { |
|
| 184 | $row = $this->getTableRow($this->getSession()->getPage(), $rowText); |
|
| 185 | if (strpos($row->getText(), $text) === false) { |
|
| 186 | throw new \Exception(sprintf('Found a row containing "%s", but it did not contain the text "%s".', $rowText, $text)); |
|
| 187 | } |
|
| 188 | } |
|
| 189 | ||
| 190 | /** |
|
| 191 | * Asset text not in a table row containing given text. |
|
| @@ 195-201 (lines=7) @@ | ||
| 192 | * |
|
| 193 | * @Then I should not see (the text ):text in the :rowText row |
|
| 194 | */ |
|
| 195 | public function assertTextNotInTableRow($text, $rowText) |
|
| 196 | { |
|
| 197 | $row = $this->getTableRow($this->getSession()->getPage(), $rowText); |
|
| 198 | if (strpos($row->getText(), $text) !== false) { |
|
| 199 | throw new \Exception(sprintf('Found a row containing "%s", but it contained the text "%s".', $rowText, $text)); |
|
| 200 | } |
|
| 201 | } |
|
| 202 | ||
| 203 | /** |
|
| 204 | * Attempts to find a link in a table row containing giving text. This is for |
|