Module: Selenium::Client::Base
- Includes:
- Extensions, GeneratedDriver, Idiomatic, Protocol
- Included in:
- Driver
- Defined in:
- lib/selenium/client/base.rb
Overview
Driver constructor and session management commands
Instance Attribute Summary collapse
-
#browser_string ⇒ Object
readonly
Returns the value of attribute browser_string.
-
#browser_url ⇒ Object
readonly
Returns the value of attribute browser_url.
-
#default_javascript_framework ⇒ Object
readonly
Returns the value of attribute default_javascript_framework.
-
#default_timeout_in_seconds ⇒ Object
readonly
Returns the value of attribute default_timeout_in_seconds.
-
#highlight_located_element_by_default ⇒ Object
readonly
Returns the value of attribute highlight_located_element_by_default.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Attributes included from Protocol
Instance Method Summary collapse
- #chrome_backend? ⇒ Boolean
- #close_current_browser_session ⇒ Object
-
#initialize(*args) ⇒ Object
Create a new client driver.
- #javascript_extension=(new_javascript_extension) ⇒ Object (also: #set_extension_js)
- #session_started? ⇒ Boolean
- #start ⇒ Object
-
#start_new_browser_session(options = {}) ⇒ Object
Starts a new browser session (launching a new browser matching configuration provided at driver creation time).
- #stop ⇒ Object
Methods included from Idiomatic
#actual_timeout_in_milliseconds, #alert, #alert?, #all_window_ids, #all_window_names, #all_window_titles, #body_text, #browser_network_traffic, #browser_xpath_library=, #checked?, #click, #confirmation, #confirmation?, #cookie, #cookie?, #cookies, #create_cookie, #delete_cookie, #element?, #execution_delay, #execution_delay=, #field, #go_back, #highlight_located_element=, #js_eval, #location, #prompt, #prompt?, #remote_control_timeout_in_seconds=, #table_cell_text, #text, #text?, #title, #value, #visible?, #wait_for, #wait_for_condition, #wait_for_page, #wait_for_popup
Methods included from Extensions
#active_javascript_framework, #wait_for_ajax, #wait_for_effects, #wait_for_element, #wait_for_field_value, #wait_for_no_element, #wait_for_no_field_value, #wait_for_no_text, #wait_for_not_visible, #wait_for_text, #wait_for_visible
Methods included from GeneratedDriver
#add_location_strategy, #add_script, #add_selection, #allow_native_xpath, #alt_key_down, #alt_key_up, #answer_on_next_prompt, #assign_id, #attach_file, #capture_entire_page_screenshot, #capture_entire_page_screenshot_to_string, #capture_screenshot, #capture_screenshot_to_string, #check, #choose_cancel_on_next_confirmation, #choose_ok_on_next_confirmation, #click, #click_at, #close, #context_menu, #context_menu_at, #control_key_down, #control_key_up, #create_cookie, #delete_all_visible_cookies, #delete_cookie, #deselect_pop_up, #double_click, #double_click_at, #drag_and_drop, #drag_and_drop_to_object, #dragdrop, #fire_event, #focus, #get_alert, #get_all_buttons, #get_all_fields, #get_all_links, #get_all_window_ids, #get_all_window_names, #get_all_window_titles, #get_attribute, #get_attribute_from_all_windows, #get_body_text, #get_confirmation, #get_cookie, #get_cookie_by_name, #get_cursor_position, #get_element_height, #get_element_index, #get_element_position_left, #get_element_position_top, #get_element_width, #get_eval, #get_expression, #get_html_source, #get_location, #get_mouse_speed, #get_prompt, #get_select_options, #get_selected_id, #get_selected_ids, #get_selected_index, #get_selected_indexes, #get_selected_label, #get_selected_labels, #get_selected_value, #get_selected_values, #get_speed, #get_table, #get_text, #get_title, #get_value, #get_whether_this_frame_match_frame_expression, #get_whether_this_window_match_window_expression, #get_xpath_count, #go_back, #highlight, #ignore_attributes_without_value, #is_alert_present, #is_checked, #is_confirmation_present, #is_cookie_present, #is_editable, #is_element_present, #is_ordered, #is_prompt_present, #is_something_selected, #is_text_present, #is_visible, #key_down, #key_down_native, #key_press, #key_press_native, #key_up, #key_up_native, #meta_key_down, #meta_key_up, #mouse_down, #mouse_down_at, #mouse_down_right, #mouse_down_right_at, #mouse_move, #mouse_move_at, #mouse_out, #mouse_over, #mouse_up, #mouse_up_at, #mouse_up_right, #mouse_up_right_at, #open, #open_window, #refresh, #remove_all_selections, #remove_script, #remove_selection, #retrieve_last_remote_control_logs, #rollup, #run_script, #select, #select_frame, #select_pop_up, #select_window, #set_browser_log_level, #set_context, #set_cursor_position, #set_mouse_speed, #set_speed, #set_timeout, #shift_key_down, #shift_key_up, #shut_down_selenium_server, #submit, #type, #type_keys, #uncheck, #use_xpath_library, #wait_for_condition, #wait_for_frame_to_load, #wait_for_page_to_load, #wait_for_pop_up, #window_focus, #window_maximize
Methods included from Protocol
#boolean_array_command, #boolean_command, #number_array_command, #number_command, #remote_control_command, #string_array_command, #string_command
Instance Attribute Details
#browser_string ⇒ Object (readonly)
Returns the value of attribute browser_string.
11 12 13 |
# File 'lib/selenium/client/base.rb', line 11 def browser_string @browser_string end |
#browser_url ⇒ Object (readonly)
Returns the value of attribute browser_url.
11 12 13 |
# File 'lib/selenium/client/base.rb', line 11 def browser_url @browser_url end |
#default_javascript_framework ⇒ Object (readonly)
Returns the value of attribute default_javascript_framework.
11 12 13 |
# File 'lib/selenium/client/base.rb', line 11 def default_javascript_framework @default_javascript_framework end |
#default_timeout_in_seconds ⇒ Object (readonly)
Returns the value of attribute default_timeout_in_seconds.
11 12 13 |
# File 'lib/selenium/client/base.rb', line 11 def default_timeout_in_seconds @default_timeout_in_seconds end |
#highlight_located_element_by_default ⇒ Object (readonly)
Returns the value of attribute highlight_located_element_by_default.
11 12 13 |
# File 'lib/selenium/client/base.rb', line 11 def highlight_located_element_by_default @highlight_located_element_by_default end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/selenium/client/base.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/selenium/client/base.rb', line 11 def port @port end |
Instance Method Details
#chrome_backend? ⇒ Boolean
106 107 108 |
# File 'lib/selenium/client/base.rb', line 106 def chrome_backend? ["*chrome", "*firefox", "*firefox2", "*firefox3"].include?(@browser_string) end |
#close_current_browser_session ⇒ Object
93 94 95 96 |
# File 'lib/selenium/client/base.rb', line 93 def close_current_browser_session remote_control_command "testComplete" if @session_id @session_id = nil end |
#initialize(*args) ⇒ Object
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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/selenium/client/base.rb', line 48 def initialize(*args) if args[0].kind_of?(Hash) = args[0] @host = [:host] @port = [:port].to_i @browser_string = [:browser] @browser_url = [:url] @default_timeout_in_seconds = ([:timeout_in_seconds] || 300).to_i @default_javascript_framework = [:javascript_framework] || :prototype @highlight_located_element_by_default = [:highlight_located_element] || false else @host = args[0] @port = args[1].to_i @browser_string = args[2] @browser_url = args[3] @default_timeout_in_seconds = (args[4] || 300).to_i @default_javascript_framework = :prototype @highlight_located_element_by_default = false end @extension_js = "" @session_id = nil end |
#javascript_extension=(new_javascript_extension) ⇒ Object Also known as: set_extension_js
110 111 112 |
# File 'lib/selenium/client/base.rb', line 110 def javascript_extension=(new_javascript_extension) @extension_js = new_javascript_extension end |
#session_started? ⇒ Boolean
72 73 74 |
# File 'lib/selenium/client/base.rb', line 72 def session_started? not @session_id.nil? end |
#start ⇒ Object
98 99 100 |
# File 'lib/selenium/client/base.rb', line 98 def start start_new_browser_session end |
#start_new_browser_session(options = {}) ⇒ Object
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)
83 84 85 86 87 88 89 90 91 |
# File 'lib/selenium/client/base.rb', line 83 def start_new_browser_session(={}) = .collect {|key,value| "#{key.to_s}=#{value.to_s}"}.sort.join(";") result = string_command "getNewBrowserSession", [@browser_string, @browser_url, @extension_js, ] @session_id = result # Consistent timeout on the remote control and driver side. # Intuitive and this is what you want 90% of the time self.remote_control_timeout_in_seconds = @default_timeout_in_seconds self.highlight_located_element = true if highlight_located_element_by_default end |
#stop ⇒ Object
102 103 104 |
# File 'lib/selenium/client/base.rb', line 102 def stop close_current_browser_session end |