2018-10-04 11:24:57 +00:00
|
|
|
import socket
|
|
|
|
|
|
|
|
|
|
|
|
# Temporary fix from https://github.com/SeleniumHQ/selenium/pull/6480
|
|
|
|
# to avoid ConnectionError in selenium
|
|
|
|
|
2020-06-28 18:24:40 +00:00
|
|
|
|
2018-10-04 11:24:57 +00:00
|
|
|
def _selenium_is_connectable(port, host="localhost"):
|
|
|
|
"""
|
|
|
|
Tries to connect to the server at port to see if it is running.
|
|
|
|
:Args:
|
|
|
|
- port - The port to connect.
|
|
|
|
"""
|
|
|
|
socket_ = None
|
|
|
|
try:
|
|
|
|
socket_ = socket.create_connection((host, port), 1)
|
|
|
|
result = True
|
|
|
|
except (socket.error, ConnectionError):
|
|
|
|
result = False
|
|
|
|
finally:
|
|
|
|
if socket_:
|
|
|
|
socket_.close()
|
|
|
|
return result
|