spec/implementation.rb in watir-webdriver-0.6.1 vs spec/implementation.rb in watir-webdriver-0.6.2
- old
+ new
@@ -9,11 +9,11 @@
set_webdriver
set_browser_args
set_guard_proc
add_html_routes
- WatirSpec.always_use_server = mobile? || ie? || safari?
+ WatirSpec.always_use_server = mobile? || ie? || safari? || remote?
end
private
def set_webdriver
@@ -25,10 +25,12 @@
args = case browser
when :firefox
firefox_args
when :chrome
chrome_args
+ when :remote
+ remote_args
else
[browser, {}]
end
if ENV['SELECTOR_STATS']
@@ -50,25 +52,35 @@
def safari?
browser == :safari
end
+ def remote?
+ browser == :remote
+ end
+
def set_guard_proc
+ matching_browser = remote? ? remote_browser : browser
matching_guards = [
- :webdriver, # guard only applies to webdriver
- browser, # guard only applies to this browser
- [:webdriver, browser] # guard only applies to this browser on webdriver
+ :webdriver, # guard only applies to webdriver
+ matching_browser, # guard only applies to this browser
+ [:webdriver, matching_browser] # guard only applies to this browser on webdriver
]
if native_events?
# guard only applies to this browser on webdriver with native events enabled
- matching_guards << [:webdriver, browser, :native_events]
+ matching_guards << [:webdriver, matching_browser, :native_events]
else
# guard only applies to this browser on webdriver with native events disabled
- matching_guards << [:webdriver, browser, :synthesized_events]
+ matching_guards << [:webdriver, matching_browser, :synthesized_events]
end
+ if !Selenium::WebDriver::Platform.linux? || ENV['DESKTOP_SESSION']
+ # some specs (i.e. Window#maximize) needs a window manager on linux
+ matching_guards << [:webdriver, matching_browser, :window_manager]
+ end
+
@imp.guard_proc = lambda { |args|
args.any? { |arg| matching_guards.include?(arg) }
}
end
@@ -98,18 +110,29 @@
end
[:chrome, opts]
end
+ def remote_args
+ [:remote, {:url => ENV["WATIR_WEBDRIVER_REMOTE_URL"] || "http://127.0.0.1:8080"}]
+ end
+
def add_html_routes
glob = File.expand_path("../html/*.html", __FILE__)
Dir[glob].each do |path|
WatirSpec::Server.get("/#{File.basename path}") { File.read(path) }
end
end
def browser
@browser ||= (ENV['WATIR_WEBDRIVER_BROWSER'] || :firefox).to_sym
+ end
+
+ def remote_browser
+ remote_browser = @imp.browser_class.new(*@imp.browser_args)
+ remote_browser.browser.name
+ ensure
+ remote_browser.close
end
def native_events?
if ENV['NATIVE_EVENTS'] == "true"
true