Class: Selenium::Server
- Inherits:
-
Object
- Object
- Selenium::Server
- Defined in:
- lib/selenium/server.rb
Overview
end
Direct Known Subclasses
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
The status of the server.
-
#timeout ⇒ Object
readonly
The timeout setting for selenium in seconds.
Class Method Summary collapse
Instance Method Summary collapse
- #driver(browser_start_command, browser_url) ⇒ Object
-
#initialize(port_number, timeout = 60) ⇒ Server
constructor
Create a selenium server that can be controlled directly.
- #open(browser_start_command, browser_url) ⇒ Object
- #print_log=(value) ⇒ Object
-
#run(*argv) ⇒ Object
Starts the server, does not return until the server shuts down.
-
#start(*argv) ⇒ Object
Starts the server, returns when the server is up and running.
-
#stop ⇒ Object
Stops the server, returns when the server is no longer running.
Constructor Details
#initialize(port_number, timeout = 60) ⇒ Server
Create a selenium server that can be controlled directly
32 33 34 35 36 37 38 39 40 |
# File 'lib/selenium/server.rb', line 32 def initialize(port_number, timeout=60) if port_number.is_a? SeleniumServer # backward compatibility, to be removed in 2.0 @server = port_number else @server = SeleniumServer.new(port_number, timeout) end @status = 'stopped' end |
Instance Attribute Details
#status ⇒ Object (readonly)
The status of the server. Values are
-
stopped
-
starting
-
started
-
stopping
-
error
22 23 24 |
# File 'lib/selenium/server.rb', line 22 def status @status end |
#timeout ⇒ Object (readonly)
The timeout setting for selenium in seconds
25 26 27 |
# File 'lib/selenium/server.rb', line 25 def timeout @timeout end |
Class Method Details
.on_port(port) ⇒ Object
27 28 29 |
# File 'lib/selenium/server.rb', line 27 def Server::on_port(port) Server.new(SeleniumServer.new(port)) end |
Instance Method Details
#driver(browser_start_command, browser_url) ⇒ Object
55 56 57 |
# File 'lib/selenium/server.rb', line 55 def driver(browser_start_command, browser_url) SeleniumDriver.new('localhost', @server.port_number, browser_start_command, browser_url, @server.request_timeout * 1000) end |
#open(browser_start_command, browser_url) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/selenium/server.rb', line 59 def open(browser_start_command, browser_url) url = URI.parse(browser_url) browser = driver(browser_start_command, URI::Generic::new(url.scheme, url.userinfo, url.host, url.port, nil, nil, nil, nil, nil)) browser.start browser.open(url.request_uri) page = WebPage.new(browser) page.wait_for_load page end |
#print_log=(value) ⇒ Object
42 43 44 |
# File 'lib/selenium/server.rb', line 42 def print_log=(value) @server.print_log = value end |
#run(*argv) ⇒ Object
Starts the server, does not return until the server shuts down
70 71 72 |
# File 'lib/selenium/server.rb', line 70 def run(*argv) @server.start(*argv) end |
#start(*argv) ⇒ Object
Starts the server, returns when the server is up and running
47 48 49 50 51 52 53 |
# File 'lib/selenium/server.rb', line 47 def start(*argv) puts "starting selenium server..." starting_server(*argv) wait_for_condition {@server.running?} puts "started selenium server" @status = 'started' end |
#stop ⇒ Object
Stops the server, returns when the server is no longer running
75 76 77 78 79 80 81 |
# File 'lib/selenium/server.rb', line 75 def stop puts "stopping selenium server..." stopping_server wait_for_condition {not @server.running?} puts "stopped selenium server." @status = 'stopped' end |