Skip to content

Commit 3ea3cd7

Browse files
committed
rb - Firefox Nightly specs passing for Windows
1 parent 94af2c2 commit 3ea3cd7

File tree

7 files changed

+40
-25
lines changed

7 files changed

+40
-25
lines changed

rb/lib/selenium/webdriver/firefox/binary.rb

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,30 @@ def path
149149
@path
150150
end
151151

152-
def version
153-
`#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
154-
end
155-
156152
def nightly_path
157153
@path = case Platform.os
158154
when :macosx
159-
nightly_path = "/Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin"
160-
nightly_path if File.exist?(nightly_path)
155+
"/Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin"
161156
when :windows
162-
Platform.find_in_program_files("\\Nightly\\firefox.exe")
157+
"#{Platform.find_in_program_files("\\Nightly\\firefox.exe").gsub('m Files (x86)', '~2')}"
163158
end
159+
160+
unless File.file?(@path.to_s) && version > 43
161+
raise Error::WebDriverError, "Could not find Firefox Nightly binary. Make sure Firefox Nightly is installed or set the path manually with #{self}.path="
162+
end
163+
164+
@path
165+
end
166+
167+
def version
168+
@version ||= case Platform.os
169+
when :macosx
170+
`#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
171+
when :windows
172+
`\"#{path}\" -v | more`.strip[/[^\s]*$/][/^\d+/].to_i
173+
else
174+
0
175+
end
164176
end
165177

166178
private

rb/lib/selenium/webdriver/firefox/w3c_bridge.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def initialize(opts = {})
4949
}
5050

5151
remote_opts.merge!(:http_client => http_client) if http_client
52-
5352
super(remote_opts)
5453
end
5554

rb/lib/selenium/webdriver/remote/w3c_bridge.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ def initialize(opts = {})
6363
opts = opts.dup
6464

6565
http_client = opts.delete(:http_client) { Http::Default.new }
66-
desired_capabilities = opts.delete(:desired_capabilities) { Capabilities.firefox }
66+
desired_capabilities = opts.delete(:desired_capabilities) { W3CCapabilities.firefox }
6767
url = opts.delete(:url) { "http://#{Platform.localhost}:4444/wd/hub" }
6868

6969
unless opts.empty?
7070
raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
7171
end
7272

7373
if desired_capabilities.kind_of?(Symbol)
74-
unless Capabilities.respond_to?(desired_capabilities)
74+
unless W3CCapabilities.respond_to?(desired_capabilities)
7575
raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
7676
end
7777

78-
desired_capabilities = Capabilities.send(desired_capabilities)
78+
desired_capabilities = W3CCapabilities.send(desired_capabilities)
7979
end
8080

8181
uri = url.kind_of?(URI) ? url : URI.parse(url)
@@ -122,7 +122,7 @@ def create_session(desired_capabilities)
122122
resp = raw_execute :newSession, {}, :desiredCapabilities => desired_capabilities
123123
@session_id = resp['sessionId'] or raise Error::WebDriverError, 'no sessionId in returned payload'
124124

125-
Capabilities.json_create resp['value']
125+
W3CCapabilities.json_create resp['value']
126126
end
127127

128128
def status
@@ -134,7 +134,7 @@ def get(url)
134134
end
135135

136136
def getCapabilities
137-
Capabilities.json_create execute(:getCapabilities)
137+
W3CCapabilities.json_create execute(:getCapabilities)
138138
end
139139

140140
def setImplicitWaitTimeout(milliseconds)

rb/lib/selenium/webdriver/remote/w3c_capabilities.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ module Remote
2727
class W3CCapabilities
2828

2929
DEFAULTS = {
30-
:browser_version => '',
31-
:platform_name => :any,
32-
:platform_version => false,
33-
:accept_ssl_certs => false,
34-
:takes_screenshot => false,
35-
:takes_element_screenshot => false,
36-
:page_load_strategy => false,
37-
:proxy => nil
30+
:browser_name => '',
31+
:browser_version => '',
32+
:platform_name => :any,
33+
:platform_version => false,
34+
:accept_ssl_certs => false,
35+
:takes_screenshot => false,
36+
:takes_element_screenshot => false,
37+
:page_load_strategy => false,
38+
:proxy => nil
3839
}
3940

4041
DEFAULTS.each_key do |key|
@@ -47,6 +48,8 @@ class W3CCapabilities
4748
end
4849
end
4950

51+
alias_method :version, :browser_version
52+
5053
#
5154
# Convenience methods for the common choices.
5255
#
@@ -67,6 +70,7 @@ def firefox(opts = {})
6770
end
6871

6972
def w3c?(opts={})
73+
return true if opts[:browser_name] == :firefox_nightly
7074
intersect = Remote::W3CCapabilities::DEFAULTS.keys & opts.keys
7175
common = [:takes_screenshot, :proxy]
7276
!(intersect - common).empty? || Firefox::Binary.version > 43

rb/spec/integration/selenium/webdriver/spec_support/guards.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def current_env
7777
:platform => Platform.os,
7878
:native => GlobalTestEnv.native_events?,
7979
:window_manager => !!ENV['DESKTOP_SESSION'],
80-
:w3c => GlobalTestEnv.w3c? || GlobalTestEnv.driver == :firefox_nightly
80+
:w3c => GlobalTestEnv.w3c?(:browser_name => GlobalTestEnv.driver)
8181
}
8282
end
8383

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def native_events?
108108
@native_events ||= !!ENV['native']
109109
end
110110

111-
def w3c?
112-
Remote::W3CCapabilities.w3c?
111+
def w3c?(opt = {})
112+
Remote::W3CCapabilities.w3c?(opt)
113113
end
114114

115115
def url_for(filename)

rb/spec/unit/selenium/client/protocol_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ProtocolClient
5757

5858
it "succeeds when given zero args" do
5959
expect(client).to receive(:remote_control_command).with(:a_verb, [])
60-
client.string_command(:a_verb)
60+
client.string_command :a_verb
6161
end
6262
end
6363

0 commit comments

Comments
 (0)