Tobias Gritschacher has submitted this change and it was merged. Change subject: Moving shared code to mediawiki-selenium Ruby gem ......................................................................
Moving shared code to mediawiki-selenium Ruby gem Bug: 53579 Change-Id: I86fa677e1bb9353dc804e2934eb6be40d325d6ff --- M selenium_cuc/Gemfile M selenium_cuc/Gemfile.lock M selenium_cuc/features/support/env.rb D selenium_cuc/features/support/sauce.rb 4 files changed, 20 insertions(+), 109 deletions(-) Approvals: Tobias Gritschacher: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/selenium_cuc/Gemfile b/selenium_cuc/Gemfile index 7d86f78..b0df5af 100644 --- a/selenium_cuc/Gemfile +++ b/selenium_cuc/Gemfile @@ -12,3 +12,4 @@ gem 'activesupport' gem 'net-http-persistent' gem 'rest-client' +gem 'mediawiki-selenium' diff --git a/selenium_cuc/Gemfile.lock b/selenium_cuc/Gemfile.lock index da9f775..79666d0 100644 --- a/selenium_cuc/Gemfile.lock +++ b/selenium_cuc/Gemfile.lock @@ -7,17 +7,17 @@ multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - atomic (1.1.13) + atomic (1.1.14) builder (3.2.2) childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) - cucumber (1.3.6) + cucumber (1.3.8) builder (>= 2.1.2) diff-lcs (>= 1.1.3) - gherkin (~> 2.12.0) - multi_json (~> 1.7.5) + gherkin (~> 2.12.1) + multi_json (>= 1.7.5, < 2.0) multi_test (>= 0.0.2) - data_magic (0.15.2) + data_magic (0.16.1) faker (>= 1.1.2) yml_reader (>= 0.2) diff-lcs (1.2.4) @@ -31,30 +31,31 @@ multi_json (~> 1.3) i18n (0.6.5) json (1.8.0) - mime-types (1.24) + mediawiki-selenium (0.1.8) + mime-types (1.25) minitest (4.7.5) - multi_json (1.7.9) + multi_json (1.8.1) multi_test (0.0.2) net-http-persistent (2.9) - page-object (0.9.1) + page-object (0.9.2) page_navigation (>= 0.8) - selenium-webdriver (>= 2.33.0) + selenium-webdriver (>= 2.35.0) watir-webdriver (>= 0.6.4) page_navigation (0.9) data_magic (>= 0.14) - require_all (1.2.1) + require_all (1.3.1) rest-client (1.6.7) mime-types (>= 1.16) - rspec-expectations (2.14.2) + rspec-expectations (2.14.3) diff-lcs (>= 1.1.3, < 2.0) rubyzip (0.9.9) - selenium-webdriver (2.35.0) + selenium-webdriver (2.35.1) childprocess (>= 0.2.5) multi_json (~> 1.0) - rubyzip + rubyzip (< 1.0.0) websocket (~> 1.0.4) syntax (1.0.0) - thread_safe (0.1.2) + thread_safe (0.1.3) atomic tzinfo (0.3.37) watir-webdriver (0.6.4) @@ -70,6 +71,7 @@ activesupport cucumber json + mediawiki-selenium net-http-persistent page-object require_all diff --git a/selenium_cuc/features/support/env.rb b/selenium_cuc/features/support/env.rb index 507db0d..57425b3 100644 --- a/selenium_cuc/features/support/env.rb +++ b/selenium_cuc/features/support/env.rb @@ -9,14 +9,10 @@ # setup & bootstrapping # before all -require 'bundler/setup' -require 'page-object' -require 'page-object/page_factory' -require 'watir-webdriver' -require 'yaml' +require 'mediawiki/selenium' + require 'net/http' require 'active_support/all' -require 'rest_client' require 'require_all' config = YAML.load_file('config/config.yml') @@ -28,25 +24,7 @@ require_all 'features/support/pages' require_all 'features/support/utils' -World(PageObject::PageFactory) - -def browser(environment, test_name, language) - if environment == :cloudbees - sauce_browser(test_name) - else - local_browser(language) - end -end - -def environment - if ENV['SAUCE_ONDEMAND_ACCESS_KEY'] && ENV['SAUCE_ONDEMAND_USERNAME'] - :cloudbees - else - :local - end -end - -def sauce_browser(test_name) +def sauce_browser(test_name, language) browsers = YAML.load_file('config/browsers.yml') if ENV['BROWSER_LABEL'] browser_label = browsers[ENV['BROWSER_LABEL']] @@ -67,64 +45,4 @@ :desired_capabilities => caps) browser -end - - -def local_browser(language) - browsers = YAML.load_file('config/browsers.yml') - if ENV['BROWSER_LABEL'] - browser_label = browsers[ENV['BROWSER_LABEL']]['name'].to_sym - else - browser_label = :firefox - end - - if language == 'default' - Watir::Browser.new browser_label - else - if browser_label == :firefox - profile = Selenium::WebDriver::Firefox::Profile.new - elsif browser_label == :chrome - profile = Selenium::WebDriver::Chrome::Profile.new - else - raise "Changing default language is currently supported only for Firefox and Chrome!" - end - profile['intl.accept_languages'] = language - Watir::Browser.new browser_label, :profile => profile - end -end - -def test_name(scenario) - if scenario.respond_to? :feature - "#{scenario.feature.name}: #{scenario.name}" - elsif scenario.respond_to? :scenario_outline - "#{scenario.scenario_outline.feature.name}: #{scenario.scenario_outline.name}: #{scenario.name}" - end -end - -Before do |scenario| - @config = config - @browser = browser(environment, test_name(scenario), 'default') - $session_id = @browser.driver.instance_variable_get(:@bridge).session_id -end - -def sauce_api(json) - url = "https://saucelabs.com/rest/v1/#{ENV['SAUCE_ONDEMAND_USERNAME']}/jobs/#{$session_id}" - - RestClient::Request.execute( - :method => :put, - :url => url, - :user => ENV['SAUCE_ONDEMAND_USERNAME'], - :password => ENV['SAUCE_ONDEMAND_ACCESS_KEY'], - :headers => {:content_type => "application/json"}, - :payload => json - ) -end - -After do |scenario| - if environment == :cloudbees - sauce_api(%Q{{"passed": #{scenario.passed?}}}) - sauce_api(%Q{{"public": true}}) - sauce_api(%Q{{"build": #{ENV['BUILD_NUMBER']}}}) if ENV['BUILD_NUMBER'] - end - @browser.close end diff --git a/selenium_cuc/features/support/sauce.rb b/selenium_cuc/features/support/sauce.rb deleted file mode 100644 index e3f82f0..0000000 --- a/selenium_cuc/features/support/sauce.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'cucumber/formatter/junit' - -module Cucumber::Formatter - class Sauce < Junit - def format_exception(exception) - sauce_job_page = "Sauce Labs job URL: http://saucelabs.com/jobs/#{$session_id}\n" - ([sauce_job_page] + ["#{exception.message} (#{exception.class})"] + exception.backtrace).join("\n") - end - end -end \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/88010 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I86fa677e1bb9353dc804e2934eb6be40d325d6ff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Zfilipin <zfili...@wikimedia.org> Gerrit-Reviewer: Cmcmahon <cmcma...@wikimedia.org> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits