Module | Selenium::Client::Base |
In: |
lib/selenium/client/base.rb
|
Driver constructor and session management commands
browser_string | [R] | |
browser_url | [R] | |
default_javascript_framework | [R] | |
default_timeout_in_seconds | [R] | |
host | [R] | |
port | [R] |
Create a new client driver
Example:
Selenium::Client::Driver.new # :host => "localhost",
:port => 4444, :browser => "*firefox", :timeout_in_seconds => 10, :url => "http://localhost:3000",
You can also set the default javascript framework used for :wait_for AJAX and effects semantics (:prototype is the default value):
Selenium::Client::Driver.new # :host => "localhost",
:port => 4444, :browser => "*firefox", :timeout_in_seconds => 10, :url => "http://localhost:3000", :javascript_framework => :jquery
# File lib/selenium/client/base.rb, line 37 37: def initialize(*args) 38: if args[0].kind_of?(Hash) 39: options = args[0] 40: @host = options[:host] 41: @port = options[:port].to_i 42: @browser_string = options[:browser] 43: @browser_url = options[:url] 44: @default_timeout_in_seconds = (options[:timeout_in_seconds] || 300).to_i 45: @default_javascript_framework = options[:javascript_framework] || :prototype 46: else 47: @host = args[0] 48: @port = args[1].to_i 49: @browser_string = args[2] 50: @browser_url = args[3] 51: @default_timeout_in_seconds = (args[4] || 300).to_i 52: @default_javascript_framework = :prototype 53: end 54: 55: @extension_js = "" 56: @session_id = nil 57: end
# File lib/selenium/client/base.rb, line 92 92: def chrome_backend? 93: ["*chrome", "*firefox", "*firefox2", "*firefox3"].include?(@browser_string) 94: end
# File lib/selenium/client/base.rb, line 79 79: def close_current_browser_session 80: remote_control_command "testComplete" if @session_id 81: @session_id = nil 82: end
# File lib/selenium/client/base.rb, line 96 96: def javascript_extension=(new_javascript_extension) 97: @extension_js = new_javascript_extension 98: end
# File lib/selenium/client/base.rb, line 59 59: def session_started? 60: not @session_id.nil? 61: end
# File lib/selenium/client/base.rb, line 100 100: def set_extension_js(new_javascript_extension) 101: javascript_extension = new_javascript_extension 102: end
Starts a new browser session (launching a new browser matching configuration provided at driver creation time).
Browser session specific option can also be provided. e.g.
driver.start_new_browser_session(:captureNetworkTraffic => true)
# File lib/selenium/client/base.rb, line 70 70: def start_new_browser_session(options={}) 71: options_as_string = options.collect {|key,value| "#{key.to_s}=#{value.to_s}"}.sort.join(";") 72: result = string_command "getNewBrowserSession", [@browser_string, @browser_url, @extension_js, options_as_string] 73: @session_id = result 74: # Consistent timeout on the remote control and driver side. 75: # Intuitive and this is what you want 90% of the time 76: self.remote_control_timeout_in_seconds = @default_timeout_in_seconds 77: end