selenium.webdriver.common.utils#
Utility functions.
Functions
|
Resolve a hostname to an IP, preferring IPv4 addresses. |
Determines a free port using sockets. |
|
|
Tries to connect to the server at port to see if it is running. |
|
Send a request to the HTTP server at the /status endpoint to verify connectivity. |
|
Joins a hostname and port together. |
|
Processes the values that will be typed in the element. |
- free_port()[source]#
Determines a free port using sockets.
First try IPv4, but use IPv6 if it can’t bind (IPv6-only system).
- Return type:
int
- find_connectable_ip(host, port=None)[source]#
Resolve a hostname to an IP, preferring IPv4 addresses.
We prefer IPv4 so that we don’t change behavior from previous IPv4-only implementations, and because some drivers (e.g., FirefoxDriver) do not support IPv6 connections.
If the optional port number is provided, only IPs that listen on the given port are considered.
- Parameters:
host (str | bytes | None) – hostname
port (int | None) – port number
- Returns:
A single IP address, as a string. If any IPv4 address is found, one is returned. Otherwise, if any IPv6 address is found, one is returned. If neither, then None is returned.
- Return type:
str | None
- join_host_port(host, port)[source]#
Joins a hostname and port together.
This is a minimal implementation intended to cope with IPv6 literals. For example, _join_host_port(‘::1’, 80) == ‘[::1]:80’.
- Parameters:
host (str) – hostname or IP
port (int) – port number
- Return type:
str
- is_connectable(port, host='localhost')[source]#
Tries to connect to the server at port to see if it is running.
- Parameters:
port (int) – port number
host (str | None) – hostname or IP
- Return type:
bool
- is_url_connectable(port, host='localhost', scheme='http')[source]#
Send a request to the HTTP server at the /status endpoint to verify connectivity.
- Parameters:
port (int | str) – port number
host (str) – hostname or IP
scheme (str) – URL scheme
- Returns:
True if the service is ready to accept new sessions, False otherwise.
- Return type:
bool