QA: Refactor for mediawiki_selenium 1.0
authorDan Duvall <dduvall@wikimedia.org>
Thu, 5 Mar 2015 22:41:11 +0000 (14:41 -0800)
committerZfilipin <zfilipin@wikimedia.org>
Fri, 6 Mar 2015 14:15:18 +0000 (14:15 +0000)
Refactored by following steps outlined in UPGRADE.md under the
mediawiki_selenium project.

Change-Id: I52717292df0541eb489b34ec083ec4a957f7546d

19 files changed:
Gemfile
Gemfile.lock
tests/browser/environment_variables [deleted file]
tests/browser/environments.yml [new file with mode: 0644]
tests/browser/features/file.feature
tests/browser/features/login.feature
tests/browser/features/preferences.feature
tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb
tests/browser/features/step_definitions/login_steps.rb
tests/browser/features/support/env.rb
tests/browser/features/support/modules/url_module.rb [deleted file]
tests/browser/features/support/pages/create_account_page.rb
tests/browser/features/support/pages/file_does_not_exist_page.rb
tests/browser/features/support/pages/main_page.rb
tests/browser/features/support/pages/preferences_appearance_page.rb
tests/browser/features/support/pages/preferences_editing_page.rb
tests/browser/features/support/pages/preferences_page.rb
tests/browser/features/support/pages/preferences_user_profile_page.rb
tests/browser/features/support/pages/ztargetpage.rb

diff --git a/Gemfile b/Gemfile
index d3f8506..4373b7f 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,5 @@
 
 source "https://rubygems.org"
 
-gem "mediawiki_api"
-gem "mediawiki_selenium"
+gem "mediawiki_selenium", "~> 1.0.1"
 gem "rubocop", require: false
index 0dc4500..148266c 100644 (file)
@@ -5,39 +5,39 @@ GEM
     astrolabe (1.3.0)
       parser (>= 2.2.0.pre.3, < 3.0)
     builder (3.2.2)
-    childprocess (0.5.3)
+    childprocess (0.5.5)
       ffi (~> 1.0, >= 1.0.11)
-    cucumber (1.3.16)
+    cucumber (1.3.19)
       builder (>= 2.1.2)
       diff-lcs (>= 1.1.3)
       gherkin (~> 2.12)
       multi_json (>= 1.7.5, < 2.0)
-      multi_test (>= 0.1.1)
-    data_magic (0.19)
+      multi_test (>= 0.1.2)
+    data_magic (0.20)
       faker (>= 1.1.2)
-      yml_reader (>= 0.3)
+      yml_reader (>= 0.4)
     diff-lcs (1.2.5)
-    domain_name (0.5.20)
+    domain_name (0.5.23)
       unf (>= 0.0.5, < 1.0.0)
     faker (1.4.3)
       i18n (~> 0.5)
-    faraday (0.9.0)
+    faraday (0.9.1)
       multipart-post (>= 1.2, < 3)
     faraday-cookie_jar (0.0.6)
       faraday (>= 0.7.4)
       http-cookie (~> 1.0.0)
-    ffi (1.9.3)
+    ffi (1.9.6)
     gherkin (2.12.2)
       multi_json (~> 1.3)
     headless (1.0.2)
     http-cookie (1.0.2)
       domain_name (~> 0.5)
-    i18n (0.6.11)
-    json (1.8.1)
-    mediawiki_api (0.2.1)
+    i18n (0.7.0)
+    json (1.8.2)
+    mediawiki_api (0.3.1)
       faraday (~> 0.9, >= 0.9.0)
       faraday-cookie_jar (~> 0.0, >= 0.0.6)
-    mediawiki_selenium (0.3.2)
+    mediawiki_selenium (1.0.1)
       cucumber (~> 1.3, >= 1.3.10)
       headless (~> 1.0, >= 1.0.1)
       json (~> 1.8, >= 1.8.1)
@@ -46,15 +46,16 @@ GEM
       rest-client (~> 1.6, >= 1.6.7)
       rspec-expectations (~> 2.14, >= 2.14.4)
       syntax (~> 1.2, >= 1.2.0)
-    mime-types (2.3)
-    multi_json (1.10.1)
-    multi_test (0.1.1)
+      thor (~> 0.19, >= 0.19.1)
+    mime-types (2.4.3)
+    multi_json (1.11.0)
+    multi_test (0.1.2)
     multipart-post (2.0.0)
-    netrc (0.7.7)
-    page-object (1.0.2)
+    netrc (0.10.3)
+    page-object (1.0.3)
       page_navigation (>= 0.9)
-      selenium-webdriver (>= 2.42.0)
-      watir-webdriver (>= 0.6.9)
+      selenium-webdriver (>= 2.44.0)
+      watir-webdriver (>= 0.6.11)
     page_navigation (0.9)
       data_magic (>= 0.14)
     parser (2.2.0.pre.4)
@@ -62,7 +63,7 @@ GEM
       slop (~> 3.4, >= 3.4.5)
     powerpack (0.0.9)
     rainbow (2.0.0)
-    rest-client (1.7.2)
+    rest-client (1.7.3)
       mime-types (>= 1.16, < 3.0)
       netrc (~> 0.7)
     rspec-expectations (2.99.2)
@@ -74,26 +75,26 @@ GEM
       rainbow (>= 1.99.1, < 3.0)
       ruby-progressbar (~> 1.4)
     ruby-progressbar (1.6.0)
-    rubyzip (1.1.6)
-    selenium-webdriver (2.42.0)
-      childprocess (>= 0.5.0)
+    rubyzip (1.1.7)
+    selenium-webdriver (2.45.0)
+      childprocess (~> 0.5)
       multi_json (~> 1.0)
       rubyzip (~> 1.0)
-      websocket (~> 1.0.4)
+      websocket (~> 1.0)
     slop (3.6.0)
     syntax (1.2.0)
+    thor (0.19.1)
     unf (0.1.4)
       unf_ext
     unf_ext (0.0.6)
-    watir-webdriver (0.6.10)
-      selenium-webdriver (>= 2.18.0)
-    websocket (1.0.7)
-    yml_reader (0.3)
+    watir-webdriver (0.7.0)
+      selenium-webdriver (>= 2.45)
+    websocket (1.2.1)
+    yml_reader (0.5)
 
 PLATFORMS
   ruby
 
 DEPENDENCIES
-  mediawiki_api
-  mediawiki_selenium
+  mediawiki_selenium (~> 1.0.1)
   rubocop
diff --git a/tests/browser/environment_variables b/tests/browser/environment_variables
deleted file mode 100644 (file)
index 25c4577..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-export MEDIAWIKI_URL=http://localhost/wiki/
-export MEDIAWIKI_API_URL=http://localhost/w/api.php
-export MEDIAWIKI_USER=Selenium_user
-export MEDIAWIKI_PASSWORD=Selenium_password
-export BROWSER=firefox
diff --git a/tests/browser/environments.yml b/tests/browser/environments.yml
new file mode 100644 (file)
index 0000000..8f8381e
--- /dev/null
@@ -0,0 +1,35 @@
+# 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:
+  mediawiki_url: http://127.0.0.1:8080/wiki/
+  mediawiki_user: Selenium_user
+  mediawiki_password: vagrant
+
+mw-vagrant-guest:
+  mediawiki_url: http://127.0.0.1/wiki/
+  mediawiki_user: Selenium_user
+  mediawiki_password: vagrant
+
+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!
index 0bd36ed..35a6675 100644 (file)
@@ -1,14 +1,3 @@
-#
-# This file is subject to the license terms in the LICENSE file found in the
-# qa-browsertests top-level directory and at
-# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
-# qa-browsertests, including this file, may be copied, modified, propagated, or
-# distributed except according to the terms contained in the LICENSE file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# qa-browsertests top-level directory and at
-# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
-#
 @chrome @clean @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @phantomjs
 Feature: File
 
index c34d23d..2cb6356 100644 (file)
@@ -1,14 +1,3 @@
-#
-# This file is subject to the license terms in the LICENSE file found in the
-# qa-browsertests top-level directory and at
-# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
-# qa-browsertests, including this file, may be copied, modified, propagated, or
-# distributed except according to the terms contained in the LICENSE file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# qa-browsertests top-level directory and at
-# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
-#
 @chrome @clean @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @phantomjs
 Feature: Log in
 
index 9e3abfd..9fed9cf 100644 (file)
@@ -1,14 +1,3 @@
-#
-# This file is subject to the license terms in the LICENSE file found in the
-# qa-browsertests top-level directory and at
-# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
-# qa-browsertests, including this file, may be copied, modified, propagated, or
-# distributed except according to the terms contained in the LICENSE file.
-#
-# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
-# qa-browsertests top-level directory and at
-# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
-#
 @chrome @clean @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @login @phantomjs
 Feature: Preferences
 
index 5271ea8..6197b6b 100644 (file)
@@ -1,6 +1,6 @@
 Given(/^I go to the "(.+)" page with content "(.+)"$/) do |page_title, page_content|
   @wikitext = page_content
-  on(APIPage).create page_title, page_content
+  api.create_page page_title, page_content
   step "I am on the #{page_title} page"
 end
 
@@ -10,7 +10,7 @@ Given(/^I am on the (.+) page$/) do |article|
 end
 
 Given(/^I create page "(.*?)" with content "(.*?)"$/) do |page_title, page_content|
-  on(APIPage).create page_title, page_content
+  api.create_page page_title, page_content
 end
 
 When(/^I click the Link Target link$/) do
@@ -18,7 +18,7 @@ When(/^I click the Link Target link$/) do
 end
 
 Then(/^I should be on the Link Target Test Page$/) do
-  @browser.url.should match(/Link_Target_Test_Page/)
+  browser.url.should match(/Link_Target_Test_Page/)
 end
 
 Then(/^the page content should contain "(.*?)"$/) do |content|
index b654b2d..f528eba 100644 (file)
@@ -14,11 +14,11 @@ Given(/^I am at Log in page$/) do
 end
 
 When(/^I log in with incorrect password$/) do
-  on(LoginPage).login_with(ENV["MEDIAWIKI_USER"], "incorrect password", false)
+  on(LoginPage).login_with(user, "incorrect password", false)
 end
 
 When(/^I log in with incorrect username$/) do
-  on(LoginPage).login_with("incorrect username", ENV["MEDIAWIKI_PASSWORD"], false)
+  on(LoginPage).login_with("incorrect username", password, false)
 end
 
 When(/^I log in without entering credentials$/) do
@@ -26,7 +26,7 @@ When(/^I log in without entering credentials$/) do
 end
 
 When(/^I log in without entering password$/) do
-  on(LoginPage).login_with(ENV["MEDIAWIKI_USER"], "", false)
+  on(LoginPage).login_with(user, "", false)
 end
 
 Then(/^error box should be visible$/) do
@@ -49,7 +49,7 @@ Then(/^Log in element should be there$/) do
 end
 
 Then(/^main page should open$/) do
-  @browser.url.should == on(MainPage).class.url
+  browser.url.should == on(MainPage).class.url
 end
 
 Then(/^Password element should be there$/) do
index 7c12236..5eff4ce 100644 (file)
@@ -1,2 +1,4 @@
-require "mediawiki_api"
-require "mediawiki_selenium"
+require 'mediawiki_selenium'
+
+require 'mediawiki_selenium/support'
+require 'mediawiki_selenium/step_definitions'
diff --git a/tests/browser/features/support/modules/url_module.rb b/tests/browser/features/support/modules/url_module.rb
deleted file mode 100644 (file)
index 6c329e8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-module URL
-  def self.url(name)
-    if ENV["MEDIAWIKI_URL"]
-      mediawiki_url = ENV["MEDIAWIKI_URL"]
-    else
-      mediawiki_url = "http://127.0.0.1:80/w/index.php"
-    end
-    "#{mediawiki_url}#{name}"
-  end
-end
index 380bccb..6a8ca69 100644 (file)
@@ -12,8 +12,7 @@
 class CreateAccountPage
   include PageObject
 
-  include URL
-  page_url URL.url("<%=params[:page_title]%>")
+  page_url "<%=params[:page_title]%>"
 
   button(:create_account, id: "wpCreateaccount")
 end
index c8491f3..9aa34d3 100644 (file)
@@ -12,8 +12,7 @@
 class FileDoesNotExistPage
   include PageObject
 
-  include URL
-  page_url URL.url("File:<%=params[:page_name]%>")
+  page_url "File:<%=params[:page_name]%>"
 
   div(:file_does_not_exist_message, id: "mw-imagepage-nofile")
 end
index 8156800..ef58d91 100644 (file)
@@ -1,8 +1,7 @@
 class MainPage
   include PageObject
 
-  include URL
-  page_url URL.url("")
+  page_url ""
 
   a(:edit_link, href: /action=edit/)
   li(:help_link, id: "n-help")
index ed4491e..0644f4c 100644 (file)
@@ -12,8 +12,7 @@
 class PreferencesAppearancePage
   include PageObject
 
-  include URL
-  page_url URL.url("Special:Preferences#mw-prefsection-rendering")
+  page_url "Special:Preferences#mw-prefsection-rendering"
 
   checkbox(:auto_number_check, id: "mw-input-wpnumberheadings")
   radio_button(:cologne_blue, id: "mw-input-wpskin-cologneblue")
index aed9c41..e8dcfae 100644 (file)
@@ -12,8 +12,7 @@
 class PreferencesEditingPage
   include PageObject
 
-  include URL
-  page_url URL.url("Special:Preferences#mw-prefsection-rendering")
+  page_url "Special:Preferences#mw-prefsection-rendering"
 
   select_list(:edit_area_font_style_select, id: "mw-input-wpeditfont")
   checkbox(:edit_section_double_click_check, id: "mw-input-wpeditondblclick")
index 919ba27..aa6848c 100644 (file)
@@ -12,8 +12,7 @@
 class PreferencesPage
   include PageObject
 
-  include URL
-  page_url URL.url("Special:Preferences")
+  page_url "Special:Preferences"
 
   a(:appearance_link, id: "preftab-rendering")
   a(:editing_link, id: "preftab-editing")
index 28e10b9..7688bba 100644 (file)
@@ -12,8 +12,7 @@
 class PreferencesUserProfilePage
   include PageObject
 
-  include URL
-  page_url URL.url("Special:Preferences#mw-prefsection-personal")
+  page_url "Special:Preferences#mw-prefsection-personal"
 
   table(:basic_info_table, id: "mw-htmlform-info")
   link(:change_password_link, text: "Change password")
index 7f168db..1e21b9e 100644 (file)
@@ -1,7 +1,7 @@
 class ZtargetPage < MainPage
-  include URL
-  page_url URL.url("<%=params[:article_name]%>")
   include PageObject
 
+  page_url "<%=params[:article_name]%>"
+
   a(:link_target_page_link, text: "link to the test target page")
 end