Skip to content
Snippets Groups Projects
Commit 1058abc9 authored by Daniel Calviño Sánchez's avatar Daniel Calviño Sánchez Committed by backportbot[bot]
Browse files

Find elements through the actor rather than the driver


"Actor::find" is a more robust way to look for elements, as it handles
some exceptions that may be thrown. Therefore, even if the elements are
not actually used and it is only checked whether they exist or not using
the actor is the preferred way when possible (and it also makes it
consistent with the rest of the acceptance tests).

Signed-off-by: default avatarDaniel Calviño Sánchez <danxuliu@gmail.com>
parent 270db2f5
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,15 @@ class AppsManagementContext implements Context, ActorAwareInterface { ...@@ -45,6 +45,15 @@ class AppsManagementContext implements Context, ActorAwareInterface {
describedAs("Enable button in the app list for $app"); describedAs("Enable button in the app list for $app");
} }
/**
* @return Locator
*/
public static function enableButtonForAnyApp() {
return Locator::forThe()->button("Enable")->
descendantOf(self::appsList())->
describedAs("Enable button in the app list for any app");
}
/** /**
* @return Locator * @return Locator
*/ */
...@@ -63,6 +72,15 @@ class AppsManagementContext implements Context, ActorAwareInterface { ...@@ -63,6 +72,15 @@ class AppsManagementContext implements Context, ActorAwareInterface {
describedAs("Disable button in the app list for $app"); describedAs("Disable button in the app list for $app");
} }
/**
* @return Locator
*/
public static function disableButtonForAnyApp() {
return Locator::forThe()->button("Disable")->
descendantOf(self::appsList())->
describedAs("Disable button in the app list for any app");
}
/** /**
* @return Locator * @return Locator
*/ */
...@@ -195,16 +213,24 @@ class AppsManagementContext implements Context, ActorAwareInterface { ...@@ -195,16 +213,24 @@ class AppsManagementContext implements Context, ActorAwareInterface {
* @Given /^I see that there are only disabled apps$/ * @Given /^I see that there are only disabled apps$/
*/ */
public function iSeeThatThereAreOnlyDisabledApps() { public function iSeeThatThereAreOnlyDisabledApps() {
$buttons = $this->actor->getSession()->getDriver()->find("//input[@value = 'Disable']"); try {
PHPUnit\Framework\Assert::assertEmpty($buttons, 'Found disabled apps'); $this->actor->find(self::disableButtonForAnyApp(), 2);
PHPUnit_Framework_Assert::fail("Found enabled apps");
} catch (NoSuchElementException $exception) {
}
} }
/** /**
* @Given /^I see that there are only enabled apps$/ * @Given /^I see that there are only enabled apps$/
*/ */
public function iSeeThatThereAreOnlyEnabledApps() { public function iSeeThatThereAreOnlyEnabledApps() {
$buttons = $this->actor->getSession()->getDriver()->find("//input[@value = 'Enable']"); try {
PHPUnit\Framework\Assert::assertEmpty($buttons, 'Found disabled apps'); $this->actor->find(self::enableButtonForAnyApp(), 2);
PHPUnit_Framework_Assert::fail("Found disabled apps");
} catch (NoSuchElementException $exception) {
}
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment