From fb734d38a9f2f7ac1914423318c292ff8f147a5f Mon Sep 17 00:00:00 2001 From: Daniel Montgomery Date: Wed, 9 Jan 2019 14:55:26 -0600 Subject: [PATCH 1/9] PL-32: Add selenium / chrome / chromedriver. --- behat.yml | 9 ++-- provisioning/federated-search-demo.yml | 1 + .../roles/selenium-webdriver/tasks/main.yml | 47 +++++++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 provisioning/roles/selenium-webdriver/tasks/main.yml diff --git a/behat.yml b/behat.yml index c6f3189..0ebaa3e 100644 --- a/behat.yml +++ b/behat.yml @@ -13,16 +13,17 @@ default: cache: ~ extensions: Behat\MinkExtension: - goutte: ~ + browser_name: 'chrome' selenium2: - wd_host: "http://127.0.0.1:8643/wd/hub" + wd_host: "http://127.0.0.1:4444/wd/hub" + capabilities: { "browserName": "chrome", "browser": "chrome", "version": "62", 'chrome': {'switches':['--no-sandbox', '--headless']}} javascript_session: selenium2 - base_url: http://federated-search-demo.local + base_url: http://d8.fs-demo.local Drupal\DrupalExtension: blackbox: ~ api_driver: 'drupal' drupal: - drupal_root: 'web' + drupal_root: 'web/d8/docroot' text: username_field: 'name' password_field: 'pass' diff --git a/provisioning/federated-search-demo.yml b/provisioning/federated-search-demo.yml index 7563298..a57b752 100644 --- a/provisioning/federated-search-demo.yml +++ b/provisioning/federated-search-demo.yml @@ -50,3 +50,4 @@ - { role: mysql } - { role: apache } - { role: solr-cors } + - { role: selenium-webdriver } diff --git a/provisioning/roles/selenium-webdriver/tasks/main.yml b/provisioning/roles/selenium-webdriver/tasks/main.yml new file mode 100644 index 0000000..e1c649f --- /dev/null +++ b/provisioning/roles/selenium-webdriver/tasks/main.yml @@ -0,0 +1,47 @@ +--- +- name: Create directory for Selenium + become: yes + file: + path: /usr/local/share/selenium + state: directory + +- name: Selenium + become: yes + get_url: + url: https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar + dest: /usr/local/share/selenium/selenium-server-standalone-3.141.59.jar + +- name: Create directory for Chromedriver + become: yes + file: + path: /usr/local/share/chromedriver + state: directory + +- name: Download Chromedriver + become: yes + unarchive: + remote_src: yes + src: https://chromedriver.storage.googleapis.com/2.45/chromedriver_linux64.zip + dest: /usr/local/share/chromedriver + mode: "+x" + +- name: "Install Chrome - Ensure Google linux signing key present" + become: yes + apt_key: + url: https://dl-ssl.google.com/linux/linux_signing_key.pub + +- name: "Install Chrome - Ensure Google Chrome repo present" + become: yes + apt_repository: + repo: "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" + filename: "google-chrome" + state: present + update_cache: yes + +- name: Install Chrome + become: yes + apt: + name: google-chrome-stable + +- name: Turn on Selenium + command: java -jar -Dwebdriver.chrome.driver="/usr/local/share/chromedriver/chromedriver" /usr/local/share/selenium/selenium-server-standalone-3.141.59.jar From 33a83cb9bec10c4d83c6af47d13fa47bc45a3f55 Mon Sep 17 00:00:00 2001 From: Daniel Montgomery Date: Wed, 9 Jan 2019 14:57:27 -0600 Subject: [PATCH 2/9] PL-32: Add very basic behat tests. These can be run from the base of the repo from inside the vm: `vendor/bin/behat --tags=javascript` Behat is configured to test the D8 site by default. The wait script was necessary since sometimes the react app wasn't loaded before the system would try to find the text. The D7 content is random, but `ex` seems to frequently be a string we can search for. --- features/bootstrap/FeatureContext.php | 8 ++++++++ features/drupal-7-search.feature | 11 +++++++++++ features/drupal-8-search.feature | 11 +++++++++++ 3 files changed, 30 insertions(+) create mode 100644 features/drupal-7-search.feature create mode 100644 features/drupal-8-search.feature diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 3c5f82a..3657f34 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -20,4 +20,12 @@ public function __construct() { } + /** + * @When I wait for :arg1 second + */ + public function iWaitForSecond($arg1) + { + sleep($arg1); + } + } diff --git a/features/drupal-7-search.feature b/features/drupal-7-search.feature new file mode 100644 index 0000000..2da6154 --- /dev/null +++ b/features/drupal-7-search.feature @@ -0,0 +1,11 @@ +@javascript +Feature: Drupal 7 search + As a site visitor + I want to see search the Drupal 7 sites + So that I can content from other sites + + Scenario: Search for "ex" + Given I visit "/search-app?search=ex" + When I wait for "1" second + Then I should see the text "Federated Search Demo (D7, domain one)" + And I should see the text "Federated Search Demo (D7, single)" diff --git a/features/drupal-8-search.feature b/features/drupal-8-search.feature new file mode 100644 index 0000000..185195f --- /dev/null +++ b/features/drupal-8-search.feature @@ -0,0 +1,11 @@ +@javascript +Feature: Drupal 8 search + As a site visitor + I want to see search the Drupal 8 sites + So that I can read recipes + + Scenario: Search for "pasta" + Given I visit "/search-app?search=pasta" + And I wait for "1" second + Then I should see the text "Super easy vegetarian pasta bake" + And I should see the text "Federated Search Demo (D8, single)" From 8e11c85fa0ef827d5e0759cc87e866d6455570e5 Mon Sep 17 00:00:00 2001 From: Daniel Montgomery Date: Wed, 9 Jan 2019 15:48:28 -0600 Subject: [PATCH 3/9] PL-32: Use phing to launch the selenium server. To test ``` vagrant reload --provision vagrant ssh phing start-selenium vendor/bin/behat --tags=javascript ``` --- build.xml | 4 ++++ provisioning/roles/selenium-webdriver/tasks/main.yml | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build.xml b/build.xml index c447e7f..29c1c81 100644 --- a/build.xml +++ b/build.xml @@ -258,5 +258,9 @@ + + + + diff --git a/provisioning/roles/selenium-webdriver/tasks/main.yml b/provisioning/roles/selenium-webdriver/tasks/main.yml index e1c649f..9fbc6c0 100644 --- a/provisioning/roles/selenium-webdriver/tasks/main.yml +++ b/provisioning/roles/selenium-webdriver/tasks/main.yml @@ -9,7 +9,7 @@ become: yes get_url: url: https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar - dest: /usr/local/share/selenium/selenium-server-standalone-3.141.59.jar + dest: /usr/local/share/selenium/selenium-server-standalone.jar - name: Create directory for Chromedriver become: yes @@ -42,6 +42,3 @@ become: yes apt: name: google-chrome-stable - -- name: Turn on Selenium - command: java -jar -Dwebdriver.chrome.driver="/usr/local/share/chromedriver/chromedriver" /usr/local/share/selenium/selenium-server-standalone-3.141.59.jar From 8d73d510bdb05bf3f78b0086996165dfaa995ff7 Mon Sep 17 00:00:00 2001 From: Daniel Montgomery Date: Fri, 11 Jan 2019 14:30:24 -0600 Subject: [PATCH 4/9] PL-32: Add functional tests for filters. The before step is needed so that the filters are visible and can be selected. --- features/bootstrap/FeatureContext.php | 27 ++++++++++++++++++ features/drupal-7-search.feature | 2 +- features/drupal-8-search-filters.feature | 36 ++++++++++++++++++++++++ features/drupal-8-search.feature | 2 +- 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 features/drupal-8-search-filters.feature diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 3657f34..04b5f96 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -28,4 +28,31 @@ public function iWaitForSecond($arg1) sleep($arg1); } + /** + * @Given I click the :arg1 element + * + * See https://stackoverflow.com/questions/33649518/how-can-i-click-a-span-in-behat. + */ + public function iClickTheElement($selector) + { + $page = $this->getSession()->getPage(); + $element = $page->find('css', $selector); + + if (empty($element)) { + throw new Exception("No html element found for the selector ('$selector')"); + } + + $element->click(); + } + + /** + * @BeforeStep + * + * Size the window so that all the elements are visible. + */ + public function beforeStep() + { + $this->getSession()->resizeWindow(1920, 1080, 'current'); + } + } diff --git a/features/drupal-7-search.feature b/features/drupal-7-search.feature index 2da6154..cd4b548 100644 --- a/features/drupal-7-search.feature +++ b/features/drupal-7-search.feature @@ -1,7 +1,7 @@ @javascript Feature: Drupal 7 search As a site visitor - I want to see search the Drupal 7 sites + I want to search the Drupal 7 sites So that I can content from other sites Scenario: Search for "ex" diff --git a/features/drupal-8-search-filters.feature b/features/drupal-8-search-filters.feature new file mode 100644 index 0000000..5b14333 --- /dev/null +++ b/features/drupal-8-search-filters.feature @@ -0,0 +1,36 @@ +@javascript +Feature: Drupal 8 search filers + As a site visitor + I want to search the Drupal 8 sites + And I want to filter my results + So that I can find relevant information more quickly + + Scenario: Filter by type + Given I visit "/search-app?search=pasta" + And I wait for "1" second + # When I expand the "Type" filter + When I click the "#solr-list-facet-ss_federated_type" element + # When I select the "Article" filter + And I check "Article" + Then I should see the text "The umami guide to our favorite mushrooms" + And I should not see the text "Super easy vegetarian pasta bake" + + Scenario: Filter by site - D8 single + Given I visit "/search-app?search=pasta" + And I wait for "1" second + # When I expand the "Site Name" filter + When I click the "#solr-list-facet-sm_site_name" element + # When I select the "Federated Search Demo (D8, single)" filter + And I check "Federated Search Demo (D8, single)" + Then I should see the text "Federated Search Demo (D8, single)" + And I should not see the text "Federated Search Demo (D8, domain one)" + + Scenario: Filter by site - D8 domain + Given I visit "/search-app?search=pasta" + And I wait for "1" second + # When I expand the "Site Name" filter + When I click the "#solr-list-facet-sm_site_name" element + # When I select the "Federated Search Demo (D8, domain one)" filter + And I check "Federated Search Demo (D8, domain one)" + Then I should see the text "Federated Search Demo (D8, domain one)" + And I should not see the text "Federated Search Demo (D8, single)" diff --git a/features/drupal-8-search.feature b/features/drupal-8-search.feature index 185195f..55d4cd9 100644 --- a/features/drupal-8-search.feature +++ b/features/drupal-8-search.feature @@ -1,7 +1,7 @@ @javascript Feature: Drupal 8 search As a site visitor - I want to see search the Drupal 8 sites + I want to search the Drupal 8 sites So that I can read recipes Scenario: Search for "pasta" From 35874dbb268bc324fdd2a027b9ca076bc975c8ac Mon Sep 17 00:00:00 2001 From: agentrickard Date: Wed, 5 Feb 2020 14:50:21 -0500 Subject: [PATCH 5/9] Updates google chrome sources. --- behat.yml | 2 +- build.xml | 1 + provisioning/roles/selenium-webdriver/tasks/main.yml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/behat.yml b/behat.yml index 0ebaa3e..43021f5 100644 --- a/behat.yml +++ b/behat.yml @@ -16,7 +16,7 @@ default: browser_name: 'chrome' selenium2: wd_host: "http://127.0.0.1:4444/wd/hub" - capabilities: { "browserName": "chrome", "browser": "chrome", "version": "62", 'chrome': {'switches':['--no-sandbox', '--headless']}} + capabilities: { "browserName": "chrome", "browser": "chrome", "version": "73", 'chrome': {'switches':['--no-sandbox', '--headless']}} javascript_session: selenium2 base_url: http://d8.fs-demo.local Drupal\DrupalExtension: diff --git a/build.xml b/build.xml index 27824e1..ce920ee 100644 --- a/build.xml +++ b/build.xml @@ -343,6 +343,7 @@ + diff --git a/provisioning/roles/selenium-webdriver/tasks/main.yml b/provisioning/roles/selenium-webdriver/tasks/main.yml index 9fbc6c0..cd78e0b 100644 --- a/provisioning/roles/selenium-webdriver/tasks/main.yml +++ b/provisioning/roles/selenium-webdriver/tasks/main.yml @@ -21,7 +21,7 @@ become: yes unarchive: remote_src: yes - src: https://chromedriver.storage.googleapis.com/2.45/chromedriver_linux64.zip + src: https://chromedriver.storage.googleapis.com/73.0.3683.68/chromedriver_mac64.zip dest: /usr/local/share/chromedriver mode: "+x" From ec380c443248d9d7ae2b0d9ca322f329d6bd3309 Mon Sep 17 00:00:00 2001 From: agentrickard Date: Wed, 5 Feb 2020 15:57:28 -0500 Subject: [PATCH 6/9] Fixes selenium install --- behat.yml | 2 +- build.xml | 16 +++++++++++----- .../roles/selenium-webdriver/tasks/main.yml | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/behat.yml b/behat.yml index 43021f5..4310061 100644 --- a/behat.yml +++ b/behat.yml @@ -16,7 +16,7 @@ default: browser_name: 'chrome' selenium2: wd_host: "http://127.0.0.1:4444/wd/hub" - capabilities: { "browserName": "chrome", "browser": "chrome", "version": "73", 'chrome': {'switches':['--no-sandbox', '--headless']}} + capabilities: { "browserName": "chrome", "browser": "chrome", "version": "72", 'chrome': {'switches':['--no-sandbox', '--headless']}} javascript_session: selenium2 base_url: http://d8.fs-demo.local Drupal\DrupalExtension: diff --git a/build.xml b/build.xml index ce920ee..67b5d0f 100644 --- a/build.xml +++ b/build.xml @@ -338,15 +338,21 @@ + + + + + + + + + + + - - - - - diff --git a/provisioning/roles/selenium-webdriver/tasks/main.yml b/provisioning/roles/selenium-webdriver/tasks/main.yml index cd78e0b..ea06c91 100644 --- a/provisioning/roles/selenium-webdriver/tasks/main.yml +++ b/provisioning/roles/selenium-webdriver/tasks/main.yml @@ -21,7 +21,7 @@ become: yes unarchive: remote_src: yes - src: https://chromedriver.storage.googleapis.com/73.0.3683.68/chromedriver_mac64.zip + src: https://chromedriver.storage.googleapis.com/72.0.3626.7/chromedriver_linux64.zip dest: /usr/local/share/chromedriver mode: "+x" From b72e6b3eb41c42e7fe0223ba9ebd418e647391be Mon Sep 17 00:00:00 2001 From: agentrickard Date: Thu, 6 Feb 2020 10:08:35 -0500 Subject: [PATCH 7/9] Auto-start selenium when running behat. --- build.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.xml b/build.xml index 67b5d0f..a9d80d5 100644 --- a/build.xml +++ b/build.xml @@ -346,9 +346,11 @@ + +