Skip to content
Prev Previous commit
Next Next commit
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: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and backportbot[bot] committed Mar 8, 2021
commit 1058abc97cb750d7f87b0afb6c836fc146b3b84e
34 changes: 30 additions & 4 deletions tests/acceptance/features/bootstrap/AppsManagementContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public static function enableButtonForApp($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
*/
Expand All @@ -63,6 +72,15 @@ public static function disableButtonForApp($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
*/
Expand Down Expand Up @@ -195,16 +213,24 @@ public function iClickOnTheApp($app) {
* @Given /^I see that there are only disabled apps$/
*/
public function iSeeThatThereAreOnlyDisabledApps() {
$buttons = $this->actor->getSession()->getDriver()->find("//input[@value = 'Disable']");
PHPUnit\Framework\Assert::assertEmpty($buttons, 'Found disabled apps');
try {
$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$/
*/
public function iSeeThatThereAreOnlyEnabledApps() {
$buttons = $this->actor->getSession()->getDriver()->find("//input[@value = 'Enable']");
PHPUnit\Framework\Assert::assertEmpty($buttons, 'Found disabled apps');
try {
$this->actor->find(self::enableButtonForAnyApp(), 2);

PHPUnit_Framework_Assert::fail("Found disabled apps");
} catch (NoSuchElementException $exception) {
}
}

/**
Expand Down