-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #635 from tienvx/refactor-commands
Refactor commands
- Loading branch information
Showing
189 changed files
with
7,773 additions
and
4,152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Alert; | ||
|
||
use Tienvx\Bundle\MbtBundle\Command\AbstractCommand; | ||
|
||
abstract class AbstractAlertCommand extends AbstractCommand | ||
{ | ||
public static function getGroup(): string | ||
{ | ||
return 'alert'; | ||
} | ||
|
||
public static function validateTarget(?string $target): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public static function getTargetHelper(): string | ||
{ | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Alert; | ||
|
||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Tienvx\Bundle\MbtBundle\Model\ValuesInterface; | ||
|
||
class AcceptAlertCommand extends AbstractAlertCommand | ||
{ | ||
public static function isTargetRequired(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public static function isValueRequired(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function run(?string $target, ?string $value, ValuesInterface $values, RemoteWebDriver $driver): void | ||
{ | ||
parent::run($target, $value, $values, $driver); | ||
$driver->switchTo()->alert()->accept(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Alert; | ||
|
||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Tienvx\Bundle\MbtBundle\Model\ValuesInterface; | ||
|
||
class AnswerPromptCommand extends AbstractAlertCommand | ||
{ | ||
public static function isTargetRequired(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public static function isValueRequired(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public static function validateTarget(?string $target): bool | ||
{ | ||
return !is_null($target); | ||
} | ||
|
||
public static function getTargetHelper(): string | ||
{ | ||
return "Propt's answer"; | ||
} | ||
|
||
public function run(?string $target, ?string $value, ValuesInterface $values, RemoteWebDriver $driver): void | ||
{ | ||
parent::run($target, $value, $values, $driver); | ||
$alert = $driver->switchTo()->alert(); | ||
$alert->sendKeys($target); | ||
$alert->accept(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Alert; | ||
|
||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Tienvx\Bundle\MbtBundle\Model\ValuesInterface; | ||
|
||
class DismissPromptCommand extends AbstractAlertCommand | ||
{ | ||
public static function isTargetRequired(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public static function isValueRequired(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function run(?string $target, ?string $value, ValuesInterface $values, RemoteWebDriver $driver): void | ||
{ | ||
parent::run($target, $value, $values, $driver); | ||
$driver->switchTo()->alert()->dismiss(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Assert; | ||
|
||
use Tienvx\Bundle\MbtBundle\Command\AbstractCommand; | ||
|
||
abstract class AbstractAssertCommand extends AbstractCommand | ||
{ | ||
public static function getGroup(): string | ||
{ | ||
return 'assert'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Assert; | ||
|
||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Tienvx\Bundle\MbtBundle\Model\ValuesInterface; | ||
|
||
class AssertAlertCommand extends AbstractAssertCommand | ||
{ | ||
public static function isTargetRequired(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public static function isValueRequired(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public static function getTargetHelper(): string | ||
{ | ||
return 'Expected value'; | ||
} | ||
|
||
public static function validateTarget(?string $target): bool | ||
{ | ||
return !is_null($target); | ||
} | ||
|
||
public function run(?string $target, ?string $value, ValuesInterface $values, RemoteWebDriver $driver): void | ||
{ | ||
parent::run($target, $value, $values, $driver); | ||
$alertText = $driver->switchTo()->alert()->getText(); | ||
$this->assert( | ||
$alertText === $target, | ||
sprintf('Actual alert text "%s" did not match "%s"', $alertText, $target) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Assert; | ||
|
||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Tienvx\Bundle\MbtBundle\Model\ValuesInterface; | ||
|
||
class AssertCheckedCommand extends AbstractAssertCommand | ||
{ | ||
public static function isTargetRequired(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public static function isValueRequired(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function run(?string $target, ?string $value, ValuesInterface $values, RemoteWebDriver $driver): void | ||
{ | ||
parent::run($target, $value, $values, $driver); | ||
$this->assert( | ||
$driver->findElement($this->getSelector($target))->isSelected(), | ||
sprintf('Element "%s" is not checked, expected to be checked', $target) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Command\Assert; | ||
|
||
use Facebook\WebDriver\Remote\RemoteWebDriver; | ||
use Tienvx\Bundle\MbtBundle\Model\ValuesInterface; | ||
|
||
class AssertCommand extends AbstractAssertCommand | ||
{ | ||
public static function isTargetRequired(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public static function isValueRequired(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public static function getTargetHelper(): string | ||
{ | ||
return 'Variable to get value from'; | ||
} | ||
|
||
public static function getValueHelper(): string | ||
{ | ||
return 'Expected value'; | ||
} | ||
|
||
public static function validateTarget(?string $target): bool | ||
{ | ||
return !empty($target); | ||
} | ||
|
||
public function run(?string $target, ?string $value, ValuesInterface $values, RemoteWebDriver $driver): void | ||
{ | ||
parent::run($target, $value, $values, $driver); | ||
$actual = $values->getValue($target); | ||
$this->assert( | ||
$actual === $value, | ||
sprintf('Actual value "%s" did not match "%s"', $actual, $value) | ||
); | ||
} | ||
} |
Oops, something went wrong.