Module Selenium::Client::Base
In: lib/selenium/client/base.rb

Driver constructor and session management commands

Methods

Included Modules

Selenium::Client::Protocol Selenium::Client::GeneratedDriver Selenium::Client::Extensions Selenium::Client::Idiomatic

Attributes

browser_string  [R] 
browser_url  [R] 
default_javascript_framework  [R] 
default_timeout_in_seconds  [R] 
highlight_located_element_by_default  [R] 
host  [R] 
port  [R] 

Public Class methods

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

You can also enables automatic highlighting of located elements by passing the highlight_located_element option, e.g.

Selenium::Client::Driver.new # :host => "localhost",

    :port => 4444,
    :browser => "*firefox",
    :highlight_located_element => true

[Source]

    # File lib/selenium/client/base.rb, line 48
48:       def initialize(*args)
49:         if args[0].kind_of?(Hash)
50:           options = args[0]
51:           @host = options[:host]
52:           @port = options[:port].to_i
53:           @browser_string = options[:browser]
54:           @browser_url = options[:url]
55:           @default_timeout_in_seconds = (options[:timeout_in_seconds] || 300).to_i
56:           @default_javascript_framework = options[:javascript_framework] || :prototype
57:           @highlight_located_element_by_default = options[:highlight_located_element] || false
58:         else
59:           @host = args[0]
60:           @port = args[1].to_i
61:           @browser_string = args[2]
62:           @browser_url = args[3]
63:           @default_timeout_in_seconds = (args[4] || 300).to_i
64:           @default_javascript_framework = :prototype
65:           @highlight_located_element_by_default = false
66:         end
67: 
68:         @extension_js = ""
69:         @session_id = nil
70:       end

Public Instance methods

[Source]

     # File lib/selenium/client/base.rb, line 106
106:       def chrome_backend?
107:         ["*chrome", "*firefox", "*firefox2", "*firefox3"].include?(@browser_string)
108:       end

[Source]

    # File lib/selenium/client/base.rb, line 93
93:       def close_current_browser_session
94:         remote_control_command "testComplete" if @session_id
95:         @session_id = nil
96:       end

[Source]

     # File lib/selenium/client/base.rb, line 110
110:       def javascript_extension=(new_javascript_extension)
111:         @extension_js = new_javascript_extension
112:       end

[Source]

    # File lib/selenium/client/base.rb, line 72
72:       def session_started?
73:         not @session_id.nil?
74:       end
set_extension_js(new_javascript_extension)

Alias for javascript_extension=

[Source]

     # File lib/selenium/client/base.rb, line 98
 98:       def start
 99:         start_new_browser_session
100:       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)

[Source]

    # File lib/selenium/client/base.rb, line 83
83:       def start_new_browser_session(options={})
84:         options_as_string = options.collect {|key,value| "#{key.to_s}=#{value.to_s}"}.sort.join(";")
85:         result = string_command "getNewBrowserSession", [@browser_string, @browser_url, @extension_js, options_as_string]
86:         @session_id = result
87:         # Consistent timeout on the remote control and driver side.
88:         # Intuitive and this is what you want 90% of the time
89:         self.remote_control_timeout_in_seconds = @default_timeout_in_seconds         
90:         self.highlight_located_element = true if highlight_located_element_by_default
91:       end

[Source]

     # File lib/selenium/client/base.rb, line 102
102:       def stop
103:               close_current_browser_session
104:       end

[Validate]