zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
U
\±djã@sòdZddlZddlmZddlmZddlmZddlmZddlmZddl    m
Z
ej e fZ ed    œd
d „Zdeeeedfeeeed œd d„Zeeed œdd„Zdeeeedœdd„Zeeefedœdd„Zeeeedœdd„ZdS)zThe Utils methods.éN)ÚIterable)ÚList)ÚOptional)ÚUnion)ÚAnyKey)ÚKeys)ÚreturncCs<t tjtj¡}| d¡| d¡| ¡d}| ¡|S)z%Determines a free port using sockets.)z    127.0.0.1réé)ÚsocketÚAF_INETÚ SOCK_STREAMÚbindÚlistenÚ getsocknameÚclose)Z free_socketÚport©rúVd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\selenium/webdriver/common/utils.pyÚ    free_port s 
 
 r)ÚhostrrcCszt |d¡}Wntjk
r(YdSXd}|D]X\}}}}}d}|rVt||dƒ}|rp|tjkrp|dS|r2|s2|tjkr2|d}q2|S)a€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.
 
    :Args:
        - host - A hostname.
        - port - Optional 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.
    NTr)r Ú getaddrinfoÚgaierrorÚis_connectabler ÚAF_INET6)rrZ    addrinfosÚipÚfamilyÚ_ZsockaddrZ connectablerrrÚfind_connectable_ip*s 
rcCs0d|kr"| d¡s"d|›d|›S|›d|›S)zù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'.
 
    :Args:
        - host - A hostname.
        - port - An integer port.
    ú:ú[z]:)Ú
startswith)rrrrrÚjoin_host_portOs
r"Ú    localhost)rrrcCsNd}z6zt ||fd¡}d}Wntk
r6d}YnXW5|rH| ¡X|S)zsTries to connect to the server at port to see if it is running.
 
    :Args:
     - port - The port to connect.
    Nr
TF)rr Úcreate_connectionÚ_is_connectable_exceptions)rrZsocket_Úresultrrrr^s
r)rrcCsHddlm}z | d|›d¡}| ¡dkWStk
rBYdSXdS)z¢Tries to connect to the HTTP server at /status path and specified port
    to see if it responds successfully.
 
    :Args:
     - port - The port to connect.
    r)Úrequestzhttp://127.0.0.1:z/statuséÈFN)Úurllibr'ÚurlopenÚgetcodeÚ    Exception)rZ url_requestÚresrrrÚis_url_connectableps  r.)ÚvaluercCs€g}|D]r}t|tƒr"| |¡qt|ttfƒrZt|ƒ}tt|ƒƒD]}| ||¡qDqtt|ƒƒD]}| ||¡qfq|S)z7Processes the values that will be typed in the element.)Ú
isinstancerÚappendÚintÚfloatÚstrÚrangeÚlen)r/Ú_typingÚvalÚirrrÚkeys_to_typing€s
 r:)N)r#)Ú__doc__r ÚtypingrrrrZselenium.typesrZselenium.webdriver.common.keysrÚerrorÚConnectionResetErrorr%r2rr4ÚbytesÚ    bytearrayrr"Úboolrr.r:rrrrÚ<module>s      
 
(%