diff --git a/Gemfile b/Gemfile index 448719aca..55e9abd14 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ source "https://rubygems.org" -gem "mediawiki_selenium", "~> 0.4.0" +gem "mediawiki_selenium", "~> 1.6.2" gem "rubocop", "~> 0.29.1", require: false diff --git a/Gemfile.lock b/Gemfile.lock index be8cdd06b..9e9b714b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,7 +5,7 @@ GEM astrolabe (1.3.1) parser (~> 2.2) builder (3.2.2) - childprocess (0.5.6) + childprocess (0.5.8) ffi (~> 1.0, >= 1.0.11) cucumber (1.3.20) builder (>= 2.1.2) @@ -17,11 +17,11 @@ GEM faker (>= 1.1.2) yml_reader (>= 0.4) diff-lcs (1.2.5) - domain_name (0.5.24) + domain_name (0.5.25) unf (>= 0.0.5, < 1.0.0) - faker (1.5.0) + faker (1.6.1) i18n (~> 0.5) - faraday (0.9.1) + faraday (0.9.2) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) faraday (>= 0.7.4) @@ -29,7 +29,7 @@ GEM ffi (1.9.10) gherkin (2.12.2) multi_json (~> 1.3) - headless (1.0.2) + headless (2.2.0) http-cookie (1.0.2) domain_name (~> 0.5) i18n (0.7.0) @@ -37,27 +37,29 @@ GEM mediawiki_api (0.5.0) faraday (~> 0.9, >= 0.9.0) faraday-cookie_jar (~> 0.0, >= 0.0.6) - mediawiki_selenium (0.4.3) - cucumber (~> 1.3, >= 1.3.10) - headless (~> 1.0, >= 1.0.1) + mediawiki_selenium (1.6.2) + cucumber (~> 1.3, >= 1.3.20) + headless (~> 2.0, >= 2.1.0) json (~> 1.8, >= 1.8.1) - mediawiki_api (~> 0.2, >= 0.2.1) + mediawiki_api (~> 0.5, >= 0.5.0) page-object (~> 1.0) rest-client (~> 1.6, >= 1.6.7) + rspec-core (~> 2.14, >= 2.14.4) rspec-expectations (~> 2.14, >= 2.14.4) syntax (~> 1.2, >= 1.2.0) - mime-types (2.6.2) + thor (~> 0.19, >= 0.19.1) + mime-types (2.99) multi_json (1.11.2) multi_test (0.1.2) multipart-post (2.0.0) - netrc (0.10.3) + netrc (0.11.0) page-object (1.1.0) page_navigation (>= 0.9) selenium-webdriver (>= 2.44.0) watir-webdriver (>= 0.6.11) page_navigation (0.9) data_magic (>= 0.14) - parser (2.2.2.6) + parser (2.2.3.0) ast (>= 1.1, < 3.0) powerpack (0.1.1) rainbow (2.0.0) @@ -65,6 +67,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) + rspec-core (2.99.2) rspec-expectations (2.99.2) diff-lcs (>= 1.1.3, < 2.0) rubocop (0.29.1) @@ -75,16 +78,17 @@ GEM ruby-progressbar (~> 1.4) ruby-progressbar (1.7.5) rubyzip (1.1.7) - selenium-webdriver (2.47.1) + selenium-webdriver (2.48.1) childprocess (~> 0.5) multi_json (~> 1.0) rubyzip (~> 1.0) websocket (~> 1.0) syntax (1.2.0) + thor (0.19.1) unf (0.1.4) unf_ext unf_ext (0.0.7.1) - watir-webdriver (0.8.0) + watir-webdriver (0.9.1) selenium-webdriver (>= 2.46.2) websocket (1.2.2) yml_reader (0.5) @@ -93,5 +97,5 @@ PLATFORMS ruby DEPENDENCIES - mediawiki_selenium (~> 0.4.0) + mediawiki_selenium (~> 1.6.2) rubocop (~> 0.29.1) diff --git a/tests/browser/environments.yml b/tests/browser/environments.yml new file mode 100644 index 000000000..35eb153f0 --- /dev/null +++ b/tests/browser/environments.yml @@ -0,0 +1,39 @@ +# Customize this configuration as necessary to provide defaults for various +# test environments. +# +# The set of defaults to use is determined by the MEDIAWIKI_ENVIRONMENT +# environment variable. +# +# export MEDIAWIKI_ENVIRONMENT=mw-vagrant-host +# bundle exec cucumber +# +# Additional variables set by the environment will override the corresponding +# defaults defined here. +# +# export MEDIAWIKI_ENVIRONMENT=mw-vagrant-host +# export MEDIAWIKI_USER=Selenium_user2 +# bundle exec cucumber +# +mw-vagrant-host: &default + user_factory: true + mediawiki_url: http://127.0.0.1:8080/wiki/ + +mw-vagrant-guest: + user_factory: true + mediawiki_url: http://127.0.0.1/wiki/ + +beta: + mediawiki_url: http://en.wikipedia.beta.wmflabs.org/wiki/ + mediawiki_user: Selenium_user + # mediawiki_password: SET THIS IN THE ENVIRONMENT! + +test2: + mediawiki_url: http://test2.wikipedia.org/wiki/ + mediawiki_user: Selenium_user + # mediawiki_password: SET THIS IN THE ENVIRONMENT! + +integration: + user_factory: true + # mediawiki_url: THIS WILL BE SET BY JENKINS + +default: *default diff --git a/tests/browser/features/step_definitions/mmv_performance_steps.rb b/tests/browser/features/step_definitions/mmv_performance_steps.rb index b7e4f4503..bc2662ae9 100644 --- a/tests/browser/features/step_definitions/mmv_performance_steps.rb +++ b/tests/browser/features/step_definitions/mmv_performance_steps.rb @@ -4,27 +4,27 @@ end Given /^I visit the Commons page$/ do @commons_open_time = Time.now.getutc - @browser.goto "https://commons.wikimedia.org/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg" + browser.goto "https://commons.wikimedia.org/wiki/File:Sunrise_over_fishing_boats_in_Kerala.jpg" end Given /^I visit an unrelated Commons page to warm up the browser cache$/ do - @browser.goto "https://commons.wikimedia.org/wiki/File:Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_16.jpg" + browser.goto "https://commons.wikimedia.org/wiki/File:Wikimedia_Foundation_2013_All_Hands_Offsite_-_Day_2_-_Photo_16.jpg" end Given /^I have a small browser window$/ do - @browser.window.resize_to 900, 700 + browser.window.resize_to 900, 700 end Given /^I have an average browser window$/ do - @browser.window.resize_to 1366, 768 + browser.window.resize_to 1366, 768 end Given /^I have a large browser window$/ do - @browser.window.resize_to 1920, 1080 + browser.window.resize_to 1920, 1080 end Given /^I am using a custom user agent$/ do - @browser = browser(test_name(@scenario), user_agent: ENV["BROWSER_USERAGENT"]) + browser(test_name(@scenario), user_agent: env[:browser_useragent]) end Then /^the File: page image is loaded$/ do diff --git a/tests/browser/features/step_definitions/mmv_steps.rb b/tests/browser/features/step_definitions/mmv_steps.rb index 688421ed0..bf95cefa6 100644 --- a/tests/browser/features/step_definitions/mmv_steps.rb +++ b/tests/browser/features/step_definitions/mmv_steps.rb @@ -44,7 +44,7 @@ When /^I click the image$/ do # Clicking the top-left corner of the image is necessary for the test to work on IE # A plain click on the image element ends up hitting the dialog, which means it won't close begin - @browser.driver.action.move_to(@browser.driver.find_element(:class, 'mw-mmv-image'), 10, 10).click.perform + browser.driver.action.move_to(browser.driver.find_element(:class, 'mw-mmv-image'), 10, 10).click.perform rescue # Plain click for web drivers that don't support mouse moves (Safari, currently) on(E2ETestPage).mmv_image_div_element.when_present.click diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb index febb48dfb..c1072b26a 100644 --- a/tests/browser/features/support/env.rb +++ b/tests/browser/features/support/env.rb @@ -1,4 +1,3 @@ -require "rubygems" -require "bundler/setup" - -Bundler.require +require 'mediawiki_selenium/cucumber' +require 'mediawiki_selenium/pages' +require 'mediawiki_selenium/step_definitions' diff --git a/tests/browser/features/support/pages/commons_page.rb b/tests/browser/features/support/pages/commons_page.rb index 4ac13ba93..285687409 100644 --- a/tests/browser/features/support/pages/commons_page.rb +++ b/tests/browser/features/support/pages/commons_page.rb @@ -3,7 +3,7 @@ require "json" class CommonsPage include PageObject - page_url URL.url("File:Sunrise_over_fishing_boats_in_Kerala.jpg") + page_url "File:Sunrise_over_fishing_boats_in_Kerala.jpg" img(:commons_image, src: /Kerala\.jpg$/) div(:mmv_image_loaded_cucumber, class: "mw-mmv-image-loaded-cucumber") diff --git a/tests/browser/features/support/pages/e2e_test_page.rb b/tests/browser/features/support/pages/e2e_test_page.rb index e4e65c17d..6c2c08a71 100644 --- a/tests/browser/features/support/pages/e2e_test_page.rb +++ b/tests/browser/features/support/pages/e2e_test_page.rb @@ -1,7 +1,7 @@ class E2ETestPage < CommonsPage include PageObject - page_url URL.url("MediaViewerE2ETest") + page_url "MediaViewerE2ETest" # Tag page elements that we will need.