Dduvall has submitted this change and it was merged.

Change subject: Removed deprecated global methods
......................................................................


Removed deprecated global methods

Change-Id: I4239f459878a25ffb81b7b438df4f803ff07b291
---
M lib/mediawiki_selenium/support/env.rb
M lib/mediawiki_selenium/support/hooks.rb
2 files changed, 3 insertions(+), 137 deletions(-)

Approvals:
  Dduvall: Looks good to me, approved



diff --git a/lib/mediawiki_selenium/support/env.rb 
b/lib/mediawiki_selenium/support/env.rb
index 4893360..5a1d5c2 100644
--- a/lib/mediawiki_selenium/support/env.rb
+++ b/lib/mediawiki_selenium/support/env.rb
@@ -24,118 +24,3 @@
 World(MediawikiSelenium::StrictPending)
 
 World { MediawikiSelenium::Environment.new(ENV) }
-
-def browser(test_name, configuration = nil)
-  if environment == :saucelabs
-    sauce_browser(test_name, configuration)
-  else
-    local_browser(configuration)
-  end
-end
-def browser_name
-  if ENV["BROWSER"]
-    ENV["BROWSER"].to_sym
-  else
-    :firefox
-  end
-end
-def environment
-  if ENV["SAUCE_ONDEMAND_USERNAME"] and ENV["SAUCE_ONDEMAND_ACCESS_KEY"] and 
ENV["BROWSER"] != "phantomjs" and ENV["HEADLESS"] != "true"
-    :saucelabs
-  else
-    :local
-  end
-end
-def local_browser(configuration)
-  if ENV["BROWSER_TIMEOUT"] && browser_name == :firefox
-    timeout = ENV["BROWSER_TIMEOUT"].to_i
-
-    client = Selenium::WebDriver::Remote::Http::Default.new
-    client.timeout = timeout
-
-    profile = Selenium::WebDriver::Firefox::Profile.new
-    profile["dom.max_script_run_time"] = timeout
-    profile["dom.max_chrome_script_run_time"] = timeout
-    browser = Watir::Browser.new browser_name, :http_client => client, 
:profile => profile
-  elsif configuration && configuration[:language] && browser_name == :firefox
-    profile = Selenium::WebDriver::Firefox::Profile.new
-    profile["intl.accept_languages"] = configuration[:language]
-    browser = Watir::Browser.new browser_name, profile: profile
-  elsif configuration && configuration[:language] && browser_name == :chrome
-    prefs = {intl: {accept_languages: configuration[:language]}}
-    browser = Watir::Browser.new browser_name, prefs: prefs
-  elsif configuration && configuration[:language] && browser_name == :phantomjs
-    capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs
-    capabilities["phantomjs.page.customHeaders.Accept-Language"] = 
configuration[:language]
-    browser = Watir::Browser.new browser_name, desired_capabilities: 
capabilities
-  elsif configuration && configuration[:user_agent] && browser_name == :firefox
-    profile = Selenium::WebDriver::Firefox::Profile.new
-    profile["general.useragent.override"] = configuration[:user_agent]
-    browser = Watir::Browser.new browser_name, profile: profile
-  else
-    browser = Watir::Browser.new browser_name
-  end
-
-  browser.window.resize_to 1280, 1024
-  set_cookie(browser)
-  browser
-end
-def sauce_api(json, session_id)
-RestClient::Request.execute(
-  :method => :put,
-  :url => 
"https://saucelabs.com/rest/v1/#{ENV['SAUCE_ONDEMAND_USERNAME']}/jobs/#{session_id}",
-  :user => ENV["SAUCE_ONDEMAND_USERNAME"],
-  :password => ENV["SAUCE_ONDEMAND_ACCESS_KEY"],
-  :headers => {:content_type => "application/json"},
-  :payload => json
-)
-end
-def sauce_browser(test_name, configuration)
-  abort "Environment variables BROWSER, PLATFORM and VERSION have to be set" 
if (ENV["BROWSER"] == nil) or (ENV["PLATFORM"] == nil) or (ENV["VERSION"] == 
nil)
-
-  client = Selenium::WebDriver::Remote::Http::Default.new
-
-  if ENV["BROWSER_TIMEOUT"] && ENV["BROWSER"] == "firefox"
-    timeout = ENV["BROWSER_TIMEOUT"].to_i
-    client.timeout = timeout
-
-    profile = Selenium::WebDriver::Firefox::Profile.new
-    profile["dom.max_script_run_time"] = timeout
-    profile["dom.max_chrome_script_run_time"] = timeout
-    caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile 
=> profile)
-  elsif configuration && configuration[:language] && ENV["BROWSER"] == 
"firefox"
-    profile = Selenium::WebDriver::Firefox::Profile.new
-    profile["intl.accept_languages"] = configuration[:language]
-    caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile 
=> profile)
-  elsif configuration && configuration[:language] && ENV["BROWSER"] == "chrome"
-    profile = Selenium::WebDriver::Chrome::Profile.new
-    profile["intl.accept_languages"] = configuration[:language]
-    caps = Selenium::WebDriver::Remote::Capabilities.chrome("chrome.profile" 
=> profile.as_json["zip"])
-  elsif configuration && configuration[:user_agent] && ENV["BROWSER"] == 
"firefox"
-    profile = Selenium::WebDriver::Firefox::Profile.new
-    profile["general.useragent.override"] = configuration[:user_agent]
-    caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile 
=> profile)
-  else
-    caps = Selenium::WebDriver::Remote::Capabilities.send(ENV["BROWSER"])
-  end
-
-  caps.platform = ENV["PLATFORM"]
-  caps.version = ENV["VERSION"]
-  caps[:name] = "#{test_name} #{ENV['JOB_NAME']}##{ENV['BUILD_NUMBER']}"
-
-  browser = Watir::Browser.new(
-    :remote,
-    http_client: client,
-    url: 
"http://#{ENV['SAUCE_ONDEMAND_USERNAME']}:#{ENV['SAUCE_ONDEMAND_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub",
-    desired_capabilities: caps)
-  browser.wd.file_detector = lambda do |args|
-    # args => ["/path/to/file"]
-    str = args.first.to_s
-    str if File.exist?(str)
-  end
-
-  browser
-end
-def set_cookie(browser)
-  # implement this method in env.rb of the repository where it is needed
-end
diff --git a/lib/mediawiki_selenium/support/hooks.rb 
b/lib/mediawiki_selenium/support/hooks.rb
index e13d8b1..9041402 100644
--- a/lib/mediawiki_selenium/support/hooks.rb
+++ b/lib/mediawiki_selenium/support/hooks.rb
@@ -75,24 +75,12 @@
   bind(:job_name, :build_number) do |job, build, options|
     options[:desired_capabilities][:name] = "#{test_name(scenario)} 
#{job}##{build}"
   end
-
-  # CirrusSearch and VisualEditor need this
-  if ENV["REUSE_BROWSER"] == "true" && $browser
-    @browser = $browser
-  elsif scenario.source_tag_names.include? "@custom-browser"
-    # browser will be started in Cucumber step
-  else
-    @browser = browser(test_name(scenario))
-    $browser = @browser # CirrusSearch and VisualEditor need this
-  end
-
-  $session_id = sauce_session_id
 end
 
 After do |scenario|
-  if @browser && scenario.failed? && (ENV["SCREENSHOT_FAILURES"] == "true")
+  if @browser && scenario.failed? && lookup(:screenshot_failures) == "true"
     require "fileutils"
-    screen_dir = ENV["SCREENSHOT_FAILURES_PATH"] || "screenshots"
+    screen_dir = lookup(:screenshot_failures_path) || "screenshots"
     FileUtils.mkdir_p screen_dir
     name = test_name(scenario).gsub(/ /, '_')
     path = "#{screen_dir}/#{name}.png"
@@ -100,12 +88,5 @@
     embed path, "image/png"
   end
 
-  if environment == :saucelabs
-    sid = $session_id || sauce_session_id
-    sauce_api(%Q{{"passed": #{scenario.passed?}}}, sid)
-    sauce_api(%Q{{"public": true}}, sid)
-    sauce_api(%Q{{"build": #{ENV["BUILD_NUMBER"]}}}, sid) if 
ENV["BUILD_NUMBER"]
-  end
-
-  teardown
+  teardown(scenario.status)
 end

-- 
To view, visit https://gerrit.wikimedia.org/r/169857
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4239f459878a25ffb81b7b438df4f803ff07b291
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/selenium
Gerrit-Branch: env-abstraction-layer
Gerrit-Owner: Dduvall <[email protected]>
Gerrit-Reviewer: Dduvall <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to