diff --git a/tests/browser/Gemfile b/tests/browser/Gemfile new file mode 100755 index 0000000..d3d93be --- /dev/null +++ b/tests/browser/Gemfile @@ -0,0 +1,6 @@ +#ruby=ruby-2.1.1 +#ruby-gemset=browsertests + +source "https://rubygems.org" + +gem "mediawiki_selenium" diff --git a/tests/browser/Gemfile.lock b/tests/browser/Gemfile.lock new file mode 100644 index 0000000..6b29163 --- /dev/null +++ b/tests/browser/Gemfile.lock @@ -0,0 +1,64 @@ +GEM + remote: https://rubygems.org/ + specs: + builder (3.2.2) + childprocess (0.5.2) + ffi (~> 1.0, >= 1.0.11) + cucumber (1.3.14) + 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.18) + faker (>= 1.1.2) + yml_reader (>= 0.2) + diff-lcs (1.2.5) + faker (1.3.0) + i18n (~> 0.5) + ffi (1.9.3) + gherkin (2.12.2) + multi_json (~> 1.3) + headless (1.0.1) + i18n (0.6.9) + json (1.8.1) + mediawiki_selenium (0.2.20) + cucumber (~> 1.3, >= 1.3.10) + headless (~> 1.0, >= 1.0.1) + json (~> 1.8, >= 1.8.1) + net-http-persistent (~> 2.9, >= 2.9.1) + page-object (~> 0.9, >= 0.9.5) + rest-client (~> 1.6, >= 1.6.7) + rspec-expectations (~> 2.14, >= 2.14.4) + syntax (~> 1.2, >= 1.2.0) + mime-types (2.2) + multi_json (1.9.2) + multi_test (0.1.1) + net-http-persistent (2.9.4) + page-object (0.9.8) + page_navigation (>= 0.9) + selenium-webdriver (>= 2.40.0) + watir-webdriver (>= 0.6.8) + page_navigation (0.9) + data_magic (>= 0.14) + rest-client (1.6.7) + mime-types (>= 1.16) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rubyzip (1.1.3) + selenium-webdriver (2.41.0) + childprocess (>= 0.5.0) + multi_json (~> 1.0) + rubyzip (~> 1.0) + websocket (~> 1.0.4) + syntax (1.2.0) + watir-webdriver (0.6.9) + selenium-webdriver (>= 2.18.0) + websocket (1.0.7) + yml_reader (0.2) + +PLATFORMS + ruby + +DEPENDENCIES + mediawiki_selenium diff --git a/tests/browser/features/math.feature b/tests/browser/features/math.feature new file mode 100644 index 0000000..1b5db83 --- /dev/null +++ b/tests/browser/features/math.feature @@ -0,0 +1,23 @@ +# +# 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 @en.wikipedia.beta.wmflabs.org @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @login @phantomjs @test2.wikipedia.org +Feature: Math + + Scenario: Display simple math + Given I am logged in + And I am at page that does not exist + And I click link Create source + When I type 3 + 2 + And I click Preview + Then the page should contain an img tag + And alt for that img should be 3 + 2 + And src for that img should come from //upload diff --git a/tests/browser/features/step_definitions/math_steps.rb b/tests/browser/features/step_definitions/math_steps.rb new file mode 100644 index 0000000..6bb9456 --- /dev/null +++ b/tests/browser/features/step_definitions/math_steps.rb @@ -0,0 +1,40 @@ +# +# 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 +# + +Given(/^I am at page that does not exist$/) do + visit(DoesNotExistPage, using_params: {page_name: @random_string}) +end + +When(/^I click link Create source$/) do + on(DoesNotExistPage).create_source_element.when_present.click +end + +When(/^I click Preview$/) do + on(EditPage).preview +end + +When(/^I type (.+)$/) do |write_text| + on(EditPage).article_text=write_text +end + +Then(/^alt for that img should be (.+)$/) do |alt| + on(EditPage).math_image_element.element.alt.should == alt +end + +Then(/^src for that img should come from (.+)$/) do |src| + on(EditPage).math_image_element.element.src.should match Regexp.escape(src) +end + + +Then(/^the page should contain an img tag$/) do + on(EditPage).math_image_element.when_present.should be_visible +end \ No newline at end of file diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb new file mode 100644 index 0000000..515ff78 --- /dev/null +++ b/tests/browser/features/support/env.rb @@ -0,0 +1,12 @@ +# +# 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 +# +require "mediawiki_selenium" diff --git a/tests/browser/features/support/pages/does_not_exist_page.rb b/tests/browser/features/support/pages/does_not_exist_page.rb new file mode 100644 index 0000000..168573f --- /dev/null +++ b/tests/browser/features/support/pages/does_not_exist_page.rb @@ -0,0 +1,19 @@ +# +# 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 +# +class DoesNotExistPage + include PageObject + + include URL + page_url URL.url("<%=params[:page_name]%>") + + a(:create_source, text: "Create source") +end \ No newline at end of file diff --git a/tests/browser/features/support/pages/edit_page.rb b/tests/browser/features/support/pages/edit_page.rb new file mode 100644 index 0000000..b0266bc --- /dev/null +++ b/tests/browser/features/support/pages/edit_page.rb @@ -0,0 +1,18 @@ +# +# 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 +# +class EditPage + include PageObject + + text_area(:article_text, id: "wpTextbox1") + img(:math_image, class: "tex") + button(:preview, id: "wpPreview") +end