Skip to content

Commit

Permalink
Merge pull request #4 from jbcr/main
Browse files Browse the repository at this point in the history
Fix Chrome options error
  • Loading branch information
macintoshplus authored Jun 24, 2021
2 parents 2c9941e + 08f0d88 commit ed2410b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 1.2.2

* Remove force W3c option for chrome because Lambdatest does not support: ` Could not open connection: w3c is not a valid option in chromeOptions capability, please refer to capability generator https://www.lambdatest.com/capabilities-generator or contact support` (2021, 24 june).
* Accept two event type on SessionStateListener.
* Remove `chromeOptions` array if empty.

# Version 1.2.1

* Add content in error message when check concurency.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This Behat extension provide a Mink Selenium2 Extension integration for [Lambdatest SaaS](https://lambdatest.com).

Tested browser :

* Firefox 88+
* Chrome 90+
* Safari 13+

## Installation

Expand Down
10 changes: 9 additions & 1 deletion src/Driver/LambdatestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,17 @@ public function buildDriver(array $config)
if ($browser === WebDriverBrowserType::CHROME &&
isset($capabilities['chromeOptions']) === true &&
isset($capabilities['chromeOptions']['w3c']) === true &&
$chromeW3c !== null &&
$capabilities['chromeOptions']['w3c'] !== $chromeW3c) {
//Restore the configuration value
$capabilities['chromeOptions']['w3c'] = $chromeW3c;
//If no option in behat configuration, remove option
if ($chromeW3c === null) {
unset($capabilities['chromeOptions']['w3c']);
}
}

if (\array_key_exists('chromeOptions', $capabilities) && \count($capabilities['chromeOptions']) === 0) {
unset($capabilities['chromeOptions']);
}

$def->setArgument(1, $capabilities);
Expand Down
15 changes: 12 additions & 3 deletions src/Listener/SessionStateListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Macintoshplus\Lambdatest\Listener;

use Behat\Mink\Mink;
use Behat\Testwork\EventDispatcher\Event\AfterExerciseAborted;
use Behat\Testwork\EventDispatcher\Event\AfterExerciseCompleted;
use Behat\Testwork\EventDispatcher\Event\ExerciseCompleted;
use Macintoshplus\Lambdatest\Driver\LambdatestWebDriver;
Expand Down Expand Up @@ -43,11 +44,19 @@ public static function getSubscribedEvents()
];
}

/*
* Define the session test state for all lambdatest session
/**
* Define the session test state for all lambdatest session.
*
* @param \Behat\Testwork\EventDispatcher\Event\AfterExerciseAborted|\Behat\Testwork\EventDispatcher\Event\AfterExerciseCompleted $event
*/
public function tearDownMinkSessions(AfterExerciseCompleted $event)
public function tearDownMinkSessions($event)
{
if (
$event instanceof AfterExerciseCompleted === false &&
$event instanceof AfterExerciseAborted === false
) {
return;
}
foreach ($this->javascriptsSessions as $sessionName) {
if ($this->mink->hasSession($sessionName) === false) {
continue;
Expand Down

0 comments on commit ed2410b

Please sign in to comment.