From da07643f28c2395efb2a3134aa15d02ac75fe55a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 20 Oct 2015 11:39:36 +1300 Subject: [PATCH 01/10] Noted --name in README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1db2c84..2d0b8aa 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,10 @@ Now you can run the tests (for example for the `framework` module): In order to run specific tests only, use their feature file name: vendor/bin/behat @framework/login.feature + +Or even run a single scenario by it's name (supports regular expressions): + + vendor/bin/behat --name 'My scenario title' @framework This will start a Firefox browser by default. Other browsers and profiles can be configured in `behat.yml`. From 19a7c52b1d3ef1c457d38afe16906b00f5c6c425 Mon Sep 17 00:00:00 2001 From: scott1702 Date: Thu, 22 Oct 2015 16:13:47 +1300 Subject: [PATCH 02/10] Add double click action --- README.md | 2 +- .../BehatExtension/Context/BasicContext.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2d0b8aa..e006b2d 100644 --- a/README.md +++ b/README.md @@ -584,7 +584,7 @@ It's based on the `vendor/bin/behat -di @cms` output. Given /^I press the "([^"]*)" button$/ - Given /^I click "([^"]*)" in the "([^"]*)" element$/ + Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element$/ Given /^I type "([^"]*)" into the dialog$/ diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 31cebed..195d139 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -383,18 +383,20 @@ JS; } /** - * @Given /^I click "([^"]*)" in the "([^"]*)" element$/ + * @Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element$/ */ - public function iClickInTheElement($text, $selector) { + public function iClickInTheElement($clickType, $text, $selector) { + $clickTypeMap = array( + "double click" => "doubleclick", + "click" => "click" + ); $page = $this->getSession()->getPage(); - $parentElement = $page->find('css', $selector); assertNotNull($parentElement, sprintf('"%s" element not found', $selector)); - $element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text)); assertNotNull($element, sprintf('"%s" not found', $text)); - - $element->click(); + $clickTypeFn = $clickTypeMap[$clickType]; + $element->$clickTypeFn(); } /** From 140c31b34f66931c44c0e2891521ed2ff3459e01 Mon Sep 17 00:00:00 2001 From: scott1702 Date: Thu, 22 Oct 2015 16:27:48 +1300 Subject: [PATCH 03/10] Add ability to confirm/dismiss dialogs after clicking in elements --- README.md | 4 ++++ .../BehatExtension/Context/BasicContext.php | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index e006b2d..cc94c6c 100644 --- a/README.md +++ b/README.md @@ -591,6 +591,10 @@ It's based on the `vendor/bin/behat -di @cms` output. Given /^I (?:press|follow) the "([^"]*)" (?:button|link), confirming the dialog$/ Given /^I (?:press|follow) the "([^"]*)" (?:button|link), dismissing the dialog$/ + + Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, confirming the dialog$/ + + Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, dismissing the dialog$/ Given /^I confirm the dialog$/ diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 195d139..008ddc6 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -398,6 +398,27 @@ JS; $clickTypeFn = $clickTypeMap[$clickType]; $element->$clickTypeFn(); } + + /** + * Needs to be in single command to avoid "unexpected alert open" errors in Selenium. + * Example: I click "Delete" in the ".actions" element, confirming the dialog + * + * @Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, confirming the dialog$/ + */ + public function iClickInTheElementConfirmingTheDialog($clickType, $text, $selector) { + $this->iClickInTheElement($clickType, $text, $selector); + $this->iConfirmTheDialog(); + } + /** + * Needs to be in single command to avoid "unexpected alert open" errors in Selenium. + * Example: I click "Delete" in the ".actions" element, dismissing the dialog + * + * @Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, dismissing the dialog$/ + */ + public function iClickInTheElementDismissingTheDialog($clickType, $text, $selector) { + $this->iClickInTheElement($clickType, $text, $selector); + $this->iDismissTheDialog(); + } /** * @Given /^I type "([^"]*)" into the dialog$/ From 12552dc808b9b950bfe9ead6931cf254c8911695 Mon Sep 17 00:00:00 2001 From: Ben Manu Date: Tue, 8 Dec 2015 11:10:19 +1300 Subject: [PATCH 04/10] FIX: params isn't defined in this context, may be carry over from PHPUnit sessions. Changing context to $state to match other env values. --- src/SilverStripe/BehatExtension/Context/SilverStripeContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php index 6d462b1..a35080c 100644 --- a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php +++ b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php @@ -203,7 +203,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex } // Fixtures - $fixtureFile = (!empty($params['fixture'])) ? $params['fixture'] : null; + $fixtureFile = (!empty($state['fixture'])) ? $state['fixture'] : null; if($fixtureFile) { $this->testSessionEnvironment->loadFixtureIntoDb($fixtureFile); } From ba103ca8fcd53677cc2ef8255352f0a4650c5871 Mon Sep 17 00:00:00 2001 From: Jeffrey Guo Date: Fri, 18 Dec 2015 15:42:48 +1300 Subject: [PATCH 05/10] add condition to prevent running endTestSession() twice reformatted with space indent --- .../Context/Initializer/SilverStripeAwareInitializer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php b/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php index 4042364..ed79843 100644 --- a/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php +++ b/src/SilverStripe/BehatExtension/Context/Initializer/SilverStripeAwareInitializer.php @@ -83,13 +83,13 @@ class SilverStripeAwareInitializer implements InitializerInterface public function __destruct() { - file_put_contents('php://stdout', "Killing test session environment..."); - + // Add condition here as register_shutdown_function() also calls this in __construct() if($this->testSessionEnvironment) { + file_put_contents('php://stdout', "Killing test session environment..."); $this->testSessionEnvironment->endTestSession(); + $this->testSessionEnvironment = null; + file_put_contents('php://stdout', " done!" . PHP_EOL); } - - file_put_contents('php://stdout', " done!" . PHP_EOL); } /** From e01cfba18ac026ca73e804e7e566ce0899d9d029 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 8 Jan 2016 13:00:08 +1300 Subject: [PATCH 06/10] Removed goutte driver from docs Not a tested driver for framework tests. Might work, but we shouldn't recommend it. Plus, we'll need to add it as a composer requirement if mentioned in `behat.yml` (see #94). --- docs/chrome-behat.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/chrome-behat.md b/docs/chrome-behat.md index 554535f..50f5b79 100644 --- a/docs/chrome-behat.md +++ b/docs/chrome-behat.md @@ -10,7 +10,6 @@ If you would like to run Behat Tests using Google Chrome here are a few steps I ``` default_session: selenium2 javascript_session: selenium2 - goutte: ~ selenium2: browser: chrome SilverStripe\BehatExtension\Extension: @@ -27,4 +26,4 @@ java -jar selenium-server.jar -Dwebdriver.chrome.driver="/path/to/chromedriver" ``` behat @mysite --profile=chrome -``` \ No newline at end of file +``` From b365210744a95a702100c332e234a5d9b80ab594 Mon Sep 17 00:00:00 2001 From: Christopher Pitt Date: Mon, 4 Apr 2016 13:17:07 +1200 Subject: [PATCH 07/10] Helpful tips on disabling Firefox auto update... --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index cc94c6c..e61771d 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,16 @@ in your project root, or set is as an environment variable in your terminal sess ## Usage +### Prevent Firefox from Automatically Updating + +The moment you open Firefox, it's going to try and update itself out of the stone age. To prevent this, open a new tab and go to `about:config`. There, change the following settings to `false`: + +- `app.update.auto` +- `app.update.enabled` +- `app.update.silent` + +Firefox will already have started the update, so close and delete it. The settings you changed should be stored as preferences, apart from the application files you've just deleted. Reinstall that ancient version. The next time you open it, and go to "About Firefox", you should see a button desperately pleading with you to "check for updates". Don't click that if you know what's good for you... + ### Starting the Selenium Server You can run the server locally in a separate Terminal session: From 858036cc8ddde2e0d072a5ca24b7fa3b0d7e2ff2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 20 Apr 2016 11:56:42 +1200 Subject: [PATCH 08/10] Updated Firefox instructions --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e61771d..4838bf1 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,9 @@ If you are having issues running Selenium with your browser please check that you're on the [latest driver](https://code.google.com/p/selenium/downloads/list), since the download link above might be out of date. -Ensure you have a supported version of firefox installed: - - wget https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/26.0/mac/en-GB/Firefox%2026.0.dmg +Download the latest [Firefox ESR](https://www.mozilla.org/en-US/firefox/organizations/all/) (Extended Support Release). +It might be older than your currently installed Firefox. +It's important to have a browser that's [supported by Selenium-Webdriver](http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp#selenium-webdriver) Now install the SilverStripe project as usual by opening it in a browser and following the instructions. Protip: You can skip this step by using `[SS_DATABASE_CHOOSE_NAME]` in a global From 7205b836154ca571dbf7c1161e4b0f0e13b43c12 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 16 May 2016 10:42:50 +1200 Subject: [PATCH 09/10] Update documentation to match travis firefox 31ESR --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4838bf1..75d95d0 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ You can run the server locally in a separate Terminal session: In some cases it may be necessary to start a specific version of firefox - java -jar selenium-server-standalone-2.41.0.jar -Dwebdriver.firefox.bin="/Applications/Firefox26.app/Contents/MacOS/firefox-bin" + java -jar selenium-server-standalone-2.41.0.jar -Dwebdriver.firefox.bin="/Applications/Firefox31.app/Contents/MacOS/firefox-bin" ### Running the Tests From ad7957587ed922f0b32ab07a78f402811c11421d Mon Sep 17 00:00:00 2001 From: William Arslett Date: Mon, 12 Dec 2016 12:12:11 +0000 Subject: [PATCH 10/10] Corrected variable name in givenTheCurrentTimeIs to address error --- .../BehatExtension/Context/SilverStripeContext.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php index a35080c..b2822e0 100644 --- a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php +++ b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php @@ -13,6 +13,7 @@ use Behat\Mink\Driver\GoutteDriver, Behat\Mink\Exception\UnsupportedDriverActionException, Behat\Mink\Exception\ElementNotFoundException; +use InvalidArgumentException; use SilverStripe\BehatExtension\Context\SilverStripeAwareContextInterface; use Symfony\Component\Yaml\Yaml; @@ -414,9 +415,9 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex * @Given /^the current time is "([^"]*)"$/ */ public function givenTheCurrentTimeIs($time) { - $newDatetime = \DateTime::createFromFormat('H:i:s', $date); + $newDatetime = \DateTime::createFromFormat('H:i:s', $time); if(!$newDatetime) { - throw new InvalidArgumentException(sprintf('Invalid date format: %s (requires "H:i:s")', $date)); + throw new InvalidArgumentException(sprintf('Invalid date format: %s (requires "H:i:s")', $time)); } $state = $this->testSessionEnvironment->getState();