From cddfe2614b224f0fd8eef95aa18ebd01bc9f4f63 Mon Sep 17 00:00:00 2001 From: jb cr <51637606+jbcr@users.noreply.github.com> Date: Fri, 28 Apr 2023 12:33:46 +0200 Subject: [PATCH] change option split_video --- README.md | 4 ++-- src/Driver/LambdatestFactory.php | 4 ++-- src/Driver/LambdatestWebDriver.php | 15 +++++++-------- src/Listener/SessionStateListener.php | 6 +++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 630ea65..e91d75d 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,11 @@ default: # You can use the LT_USERNAME and LT_USERKEY environment variables instead of this keys: user: your_email@domain.tld # Your Lambdatest login key: xxxxx # Your Lambdatest key available here: https://accounts.lambdatest.com/detail/profile - split_video: false #If false, run all scenario in one session. If true, close and open a new session for each scenario + restart_session_between_scenario: false #If false, run all scenario in one session. If true, close and open a new session for each scenario # The rest of key are the same as Mink Extension wd_host: https://hub.lambdatest.com/wd/hub # The URL of Selenium2 Hub capabilities: - name: Behat test suite # Define the name to change the Lambdatest session name or prefix if `split_video` is true + name: Behat test suite # Define the name to change the Lambdatest session name or prefix if `restart_session_between_scenario` is true # The rest of key are the same as Mink Extension browser: firefox # The browser name marionette: true diff --git a/src/Driver/LambdatestFactory.php b/src/Driver/LambdatestFactory.php index d6faf81..d6c70ac 100644 --- a/src/Driver/LambdatestFactory.php +++ b/src/Driver/LambdatestFactory.php @@ -27,7 +27,7 @@ public function configure(ArrayNodeDefinition $builder) $builder->children() ->scalarNode('user')->end() ->scalarNode('key')->end() - ->booleanNode('split_video')->defaultFalse()->end() + ->booleanNode('restart_session_between_scenario')->defaultFalse()->end() ->end(); parent::configure($builder); } @@ -71,7 +71,7 @@ public function buildDriver(array $config) $def = parent::buildDriver($config); $def->setClass(LambdatestWebDriver::class); - $def->setArgument(3, $config['split_video']); + $def->setArgument(3, $config['restart_session_between_scenario']); $capabilities = $def->getArgument(1); // Remove w3c option is no Chrome browser diff --git a/src/Driver/LambdatestWebDriver.php b/src/Driver/LambdatestWebDriver.php index 77615cb..61d7fbb 100644 --- a/src/Driver/LambdatestWebDriver.php +++ b/src/Driver/LambdatestWebDriver.php @@ -8,33 +8,32 @@ use Facebook\WebDriver\Exception\InvalidSessionIdException; use Facebook\WebDriver\Exception\UnrecognizedExceptionException; use Facebook\WebDriver\Remote\RemoteWebDriver; +use SilverStripe\MinkFacebookWebDriver\FacebookWebDriver; /* * Override the WebDriver to add quit call on session stop. * Use the LambdatestWebDriver allow to set the test result on lambdatest. */ -final class LambdatestWebDriver extends \SilverStripe\MinkFacebookWebDriver\FacebookWebDriver +final class LambdatestWebDriver extends FacebookWebDriver { protected $webDriver; - private $started = false; - - private bool $splitVideo; + private bool $restartSessionBetweenScenario; public function __construct( $browserName = self::DEFAULT_BROWSER, $desiredCapabilities = [], $wdHost = 'http://localhost:4444/wd/hub', - $splitVideo = false + $restartSessionBetweenScenario = false ) { parent::__construct($browserName, $desiredCapabilities, $wdHost); - $this->splitVideo = $splitVideo; + $this->restartSessionBetweenScenario = $restartSessionBetweenScenario; } - public function isSplitVideo(): bool + public function isRestartSessionBetweenScenario(): bool { - return $this->splitVideo; + return $this->restartSessionBetweenScenario; } public function setWebDriver(RemoteWebDriver $webDriver) diff --git a/src/Listener/SessionStateListener.php b/src/Listener/SessionStateListener.php index 52e8f76..54580af 100644 --- a/src/Listener/SessionStateListener.php +++ b/src/Listener/SessionStateListener.php @@ -88,7 +88,7 @@ public function tearDownMinkSessions($event) public function beforeScenario(BeforeScenarioTested $event): void { $driver = $this->getMinkLambdatestSession(); - if ($driver === null || $driver->isSplitVideo() === false) { + if ($driver === null || $driver->isRestartSessionBetweenScenario() === false) { return; } if (empty($this->originalTags)) { @@ -113,7 +113,7 @@ public function beforeScenario(BeforeScenarioTested $event): void public function afterScenarioOrOutline(AfterTested $event): void { $driver = $this->getMinkLambdatestSession(); - if ($driver === null || $driver->getWebDriver() === null || $driver->isSplitVideo() === false) { + if ($driver === null || $driver->getWebDriver() === null || $driver->isRestartSessionBetweenScenario() === false) { return; } $driver->executeScript('lambda-status='.($event->getTestResult()->isPassed() ? 'passed' : 'failed')); @@ -127,7 +127,7 @@ public function afterScenarioOrOutline(AfterTested $event): void public function beforeOutline(BeforeOutlineTested $event): void { $driver = $this->getMinkLambdatestSession(); - if ($driver === null || $driver->isSplitVideo() === false) { + if ($driver === null || $driver->isRestartSessionBetweenScenario() === false) { return; } if (empty($this->originalTags)) {