mediawiki_selenium 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99b7b4ccc4f6df7bc91ad09c998b40fd82474713
4
- data.tar.gz: 9ce4df71916e28f2fad9b6820b2a17fa658b5af1
3
+ metadata.gz: 803af6a3b0e01b71f76fdc2f8b5a386a68275c76
4
+ data.tar.gz: 7fa1c41c012a31f926cb147f213b6b2b3de2b7de
5
5
  SHA512:
6
- metadata.gz: 94e23716e38d82fb75f48963f7829cb6576587f0d233b031f24b911d3c7afe4b862969d5317210898c44ef0368c2dcafdee0b65cc2bacbae0a76acbe3410c646
7
- data.tar.gz: 0463a7435c9bca068acd42d61f65e4f7ee180790a0956fa25c070d9c1791568b5055c4fbb4692c2deb0bb187dd86925831d78063d42eeeee17bc2d320f150b1d
6
+ metadata.gz: aee7c180a02d04d8407b442682ead80a33fa9079228578cbce893799aecbb51c112b64be81f188c4557e35aac4d9f310119fa608e133f1341d3e4cbe6934d446
7
+ data.tar.gz: daa100d2ce022f1077b3007aa6d0354bd5879f2ee5e5e67bd82caaced05541a4b22e93b7e3e12a44d73ad9a0f3e667f43c8831cf69eda43ec7f11d92111f6362
@@ -19,11 +19,11 @@ require "yaml"
19
19
 
20
20
  World(PageObject::PageFactory)
21
21
 
22
- def browser(environment, test_name, language)
22
+ def browser(test_name, configuration = nil)
23
23
  if environment == :saucelabs
24
- sauce_browser(test_name, language)
24
+ sauce_browser(test_name, configuration)
25
25
  else
26
- local_browser(language)
26
+ local_browser(configuration)
27
27
  end
28
28
  end
29
29
  def environment
@@ -33,14 +33,14 @@ def environment
33
33
  :local
34
34
  end
35
35
  end
36
- def local_browser(language)
36
+ def local_browser(configuration)
37
37
  if ENV["BROWSER"]
38
38
  browser_name = ENV["BROWSER"].to_sym
39
39
  else
40
40
  browser_name = :firefox
41
41
  end
42
42
 
43
- if language == "default" && ENV["BROWSER_TIMEOUT"] && browser_name == :firefox
43
+ if ENV["BROWSER_TIMEOUT"] && browser_name == :firefox
44
44
  timeout = ENV["BROWSER_TIMEOUT"].to_i
45
45
 
46
46
  client = Selenium::WebDriver::Remote::Http::Default.new
@@ -50,24 +50,23 @@ def local_browser(language)
50
50
  profile["dom.max_script_run_time"] = timeout
51
51
  profile["dom.max_chrome_script_run_time"] = timeout
52
52
  browser = Watir::Browser.new browser_name, :http_client => client, :profile => profile
53
- elsif language == "default"
54
- browser = Watir::Browser.new browser_name
53
+ elsif configuration && configuration[:language] && browser_name == :firefox
54
+ profile = Selenium::WebDriver::Firefox::Profile.new
55
+ profile["intl.accept_languages"] = configuration[:language]
56
+ browser = Watir::Browser.new browser_name, profile: profile
57
+ elsif configuration && configuration[:language] && browser_name == :chrome
58
+ prefs = {intl: {accept_languages: configuration[:language]}}
59
+ browser = Watir::Browser.new browser_name, prefs: prefs
60
+ elsif configuration && configuration[:language] && browser_name == :phantomjs
61
+ capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs
62
+ capabilities["phantomjs.page.customHeaders.Accept-Language"] = configuration[:language]
63
+ browser = Watir::Browser.new browser_name, desired_capabilities: capabilities
64
+ elsif configuration && configuration[:user_agent] && browser_name == :firefox
65
+ profile = Selenium::WebDriver::Firefox::Profile.new
66
+ profile["general.useragent.override"] = configuration[:user_agent]
67
+ browser = Watir::Browser.new browser_name, profile: profile
55
68
  else
56
- if browser_name == :firefox
57
- profile = Selenium::WebDriver::Firefox::Profile.new
58
- profile["intl.accept_languages"] = language
59
- browser = Watir::Browser.new browser_name, profile: profile
60
- elsif browser_name == :chrome
61
- profile = Selenium::WebDriver::Chrome::Profile.new
62
- profile["intl.accept_languages"] = language
63
- browser = Watir::Browser.new browser_name, profile: profile
64
- elsif browser_name == :phantomjs
65
- capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs
66
- capabilities["phantomjs.page.customHeaders.Accept-Language"] = language
67
- browser = Watir::Browser.new browser_name, desired_capabilities: capabilities
68
- else
69
- raise "Changing default language is currently supported only for Chrome, Firefox and PhantomJS!"
70
- end
69
+ browser = Watir::Browser.new browser_name
71
70
  end
72
71
 
73
72
  browser.window.resize_to 1280, 1024
@@ -83,13 +82,13 @@ RestClient::Request.execute(
83
82
  :payload => json
84
83
  )
85
84
  end
86
- def sauce_browser(test_name, language)
85
+ def sauce_browser(test_name, configuration)
87
86
  abort "Environment variables BROWSER, PLATFORM and VERSION have to be set" if (ENV["BROWSER"] == nil) or (ENV["PLATFORM"] == nil) or (ENV["VERSION"] == nil)
88
87
 
89
88
  require "selenium/webdriver/remote/http/persistent" # http_client
90
89
  client = Selenium::WebDriver::Remote::Http::Persistent.new
91
90
 
92
- if language == "default" && ENV["BROWSER_TIMEOUT"] && ENV["BROWSER"] == "firefox"
91
+ if ENV["BROWSER_TIMEOUT"] && ENV["BROWSER"] == "firefox"
93
92
  timeout = ENV["BROWSER_TIMEOUT"].to_i
94
93
  client.timeout = timeout
95
94
 
@@ -97,16 +96,20 @@ def sauce_browser(test_name, language)
97
96
  profile["dom.max_script_run_time"] = timeout
98
97
  profile["dom.max_chrome_script_run_time"] = timeout
99
98
  caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
100
- elsif language == "default"
101
- caps = Selenium::WebDriver::Remote::Capabilities.send(ENV["BROWSER"])
102
- elsif ENV["BROWSER"] == "firefox"
99
+ elsif configuration && configuration[:language] && ENV["BROWSER"] == "firefox"
103
100
  profile = Selenium::WebDriver::Firefox::Profile.new
104
- profile["intl.accept_languages"] = language
101
+ profile["intl.accept_languages"] = configuration[:language]
105
102
  caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
106
- elsif ENV["BROWSER"] == "chrome"
103
+ elsif configuration && configuration[:language] && ENV["BROWSER"] == "chrome"
107
104
  profile = Selenium::WebDriver::Chrome::Profile.new
108
- profile["intl.accept_languages"] = language
105
+ profile["intl.accept_languages"] = configuration[:language]
109
106
  caps = Selenium::WebDriver::Remote::Capabilities.chrome("chrome.profile" => profile.as_json["zip"])
107
+ elsif configuration && configuration[:user_agent] && ENV["BROWSER"] == "firefox"
108
+ profile = Selenium::WebDriver::Firefox::Profile.new
109
+ profile["general.useragent.override"] = configuration[:user_agent]
110
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
111
+ else
112
+ caps = Selenium::WebDriver::Remote::Capabilities.send(ENV["BROWSER"])
110
113
  end
111
114
 
112
115
  caps.platform = ENV["PLATFORM"]
@@ -26,7 +26,7 @@ Before do |scenario|
26
26
  elsif scenario.source_tag_names.include? "@custom-browser"
27
27
  # browser will be started in Cucumber step
28
28
  else
29
- @browser = browser(environment, test_name(scenario), "default")
29
+ @browser = browser(test_name(scenario))
30
30
  $browser = @browser # CirrusSearch and VisualEditor need this
31
31
  $session_id = @browser.driver.instance_variable_get(:@bridge).session_id
32
32
  end
@@ -10,5 +10,5 @@ https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
10
  =end
11
11
 
12
12
  module MediawikiSelenium
13
- VERSION = "0.2.12"
13
+ VERSION = "0.2.13"
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki_selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris McMahon
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-03-13 00:00:00.000000000 Z
15
+ date: 2014-03-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: cucumber