Class: Selenium::WebDriver::Edge::Service Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Edge::Service
- Defined in:
- lib/selenium/webdriver/edge/service.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- START_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
20
- SOCKET_LOCK_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
45
- STOP_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
5
- DEFAULT_PORT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
17556
- MISSING_TEXT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"Unable to find MicrosoftWebDriver. Please download the server from https://www.microsoft.com/en-us/download/details.aspx?id=48212. More info at https://github.com/SeleniumHQ/selenium/wiki/MicrosoftWebDriver."
Class Method Summary collapse
- .default_service(*extra_args) ⇒ Object private
- .executable_path ⇒ Object private
- .executable_path=(path) ⇒ Object private
Instance Method Summary collapse
- #connect_until_stable ⇒ Object private
- #find_free_port ⇒ Object private
-
#initialize(executable_path, port, *extra_args) ⇒ Service
constructor
private
A new instance of Service.
- #socket_lock ⇒ Object private
- #start ⇒ Object private
- #start_process ⇒ Object private
- #stop ⇒ Object private
- #uri ⇒ Object private
Constructor Details
#initialize(executable_path, port, *extra_args) ⇒ Service
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Service.
53 54 55 56 57 58 59 60 61 |
# File 'lib/selenium/webdriver/edge/service.rb', line 53 def initialize(executable_path, port, *extra_args) @executable_path = executable_path @host = Platform.localhost @port = Integer(port) raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1 @extra_args = extra_args end |
Class Method Details
.default_service(*extra_args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/selenium/webdriver/edge/service.rb', line 49 def self.default_service(*extra_args) new executable_path, DEFAULT_PORT, *extra_args end |
.executable_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 40 41 42 |
# File 'lib/selenium/webdriver/edge/service.rb', line 34 def self.executable_path @executable_path ||= ( path = Platform.find_binary "MicrosoftWebDriver" path or raise Error::WebDriverError, MISSING_TEXT Platform.assert_executable path path ) end |
.executable_path=(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 |
# File 'lib/selenium/webdriver/edge/service.rb', line 44 def self.executable_path=(path) Platform.assert_executable path @executable_path = path end |
Instance Method Details
#connect_until_stable ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
105 106 107 108 109 110 111 |
# File 'lib/selenium/webdriver/edge/service.rb', line 105 def connect_until_stable @socket_poller = SocketPoller.new @host, @port, START_TIMEOUT unless @socket_poller.connected? raise Error::WebDriverError, "unable to connect to MicrosoftWebDriver #{@host}:#{@port}" end end |
#find_free_port ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 |
# File 'lib/selenium/webdriver/edge/service.rb', line 93 def find_free_port @port = PortProber.above @port end |
#socket_lock ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
113 114 115 |
# File 'lib/selenium/webdriver/edge/service.rb', line 113 def socket_lock @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT) end |
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 68 69 70 71 |
# File 'lib/selenium/webdriver/edge/service.rb', line 63 def start Platform.exit_hook { stop } # make sure we don't leave the server running socket_lock.locked do find_free_port start_process connect_until_stable end end |
#start_process ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
97 98 99 100 101 102 103 |
# File 'lib/selenium/webdriver/edge/service.rb', line 97 def start_process server_command = [@executable_path, "--port=#{@port}", *@extra_args] @process = ChildProcess.build(*server_command) @process.io.inherit! if $DEBUG == true @process.start end |
#stop ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/selenium/webdriver/edge/service.rb', line 73 def stop return if @process.nil? || @process.exited? Net::HTTP.start(@host, @port) do |http| http.open_timeout = STOP_TIMEOUT / 2 http.read_timeout = STOP_TIMEOUT / 2 http.head("/shutdown") end @process.poll_for_exit STOP_TIMEOUT rescue ChildProcess::TimeoutError # ok, force quit @process.stop STOP_TIMEOUT end |
#uri ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 |
# File 'lib/selenium/webdriver/edge/service.rb', line 89 def uri URI.parse "http://#{@host}:#{@port}" end |