zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
U
\±d9ã@sÞddlZddlZddlZddlZddlZddlmZddlmZddl    m
Z
ddl m Z ddl mZddlmZdd    lmZdd
lmZdd lmZdd lmZdd lmZddlmZe e¡ZdZ dZ!Gdd„deƒZdS)éN)Úcontextmanager)ÚBytesIO)Úrmtree)ÚDesiredCapabilities)Ú DriverFinder)Ú    WebDriveré)Ú FirefoxBinary)ÚFirefoxProfile)ÚOptions)ÚFirefoxRemoteConnection)ÚDEFAULT_EXECUTABLE_PATH)ÚServicezgeckodriver.logc sàeZdZdZdZddddededddedf ddœ‡fdd„ Zddœ‡fdd    „ Z    ddœd
d „Z
e d d „ƒZ ddœdd„Z edd„ƒZdedœdd„Zddœdd„Zedœdd„Zedœdd„Zedœdd„Zedœdd„Z‡ZS) rZchromeÚcontentNT)Úreturnc sÜ|tkrtjdtdd|s |
r0tjdtdd|rDtjdtddd|_|r^tjdtddd|_| tkr|tjdtdd|tkr”tjd    tdd|r¨tjd
tdd|    |_|sº|
rº|
}|sÈt    j
  ¡}|sÒt ƒ}t |ƒ}| d ¡rî|d |_|r|jr|j|_|jr|j|_|r:t|tƒr.t|ƒ}||_||_|r`t|tƒrTt|ƒ}||_||_| d ¡rt|jszd |_|js’t|||d|_t |j|¡|j_|j ¡t|jj|jd} tƒj| |ddd |_dS)ac Starts a new local session of Firefox.
 
        Based on the combination and specificity of the various keyword
        arguments, a capabilities dictionary will be constructed that
        is passed to the remote end.
 
        The keyword arguments given to this constructor are helpers to
        more easily allow Firefox WebDriver sessions to be customised
        with different options.  They are mapped on to a capabilities
        dictionary that is passed on to the remote end.
 
        As some of the options, such as `firefox_profile` and
        `options.profile` are mutually exclusive, precedence is
        given from how specific the setting is.  `capabilities` is the
        least specific keyword argument, followed by `options`,
        followed by `firefox_binary` and `firefox_profile`.
 
        In practice this means that if `firefox_profile` and
        `options.profile` are both set, the selected profile
        instance will always come from the most specific variable.
        In this case that would be `firefox_profile`.  This will result in
        `options.profile` to be ignored because it is considered
        a less specific setting than the top-level `firefox_profile`
        keyword argument.  Similarly, if you had specified a
        `capabilities["moz:firefoxOptions"]["profile"]` Base64 string,
        this would rank below `options.profile`.
 
        :param firefox_profile: Deprecated: Instance of ``FirefoxProfile`` object
            or a string.  If undefined, a fresh profile will be created
            in a temporary location on the system.
        :param firefox_binary: Deprecated: Instance of ``FirefoxBinary`` or full
            path to the Firefox binary.  If undefined, the system default
            Firefox installation will  be used.
        :param capabilities: Deprecated: Dictionary of desired capabilities.
        :param proxy: Deprecated: The proxy settings to use when communicating with
            Firefox via the extension connection.
        :param executable_path: Deprecated: Full path to override which geckodriver
            binary to use for Firefox 47.0.1 and greater, which
            defaults to picking up the binary from the system path.
        :param options: Instance of ``options.Options``.
        :param service: (Optional) service instance for managing the starting and stopping of the driver.
        :param service_log_path: Deprecated: Where to log information from the driver.
        :param service_args: Deprecated: List of args to pass to the driver service
        :param desired_capabilities: Deprecated: alias of capabilities. In future
            versions of this library, this will replace 'capabilities'.
            This will make the signature consistent with RemoteWebDriver.
        :param keep_alive: Whether to configure remote_connection.RemoteConnection to use
             HTTP keep-alive.
        zDexecutable_path has been deprecated, please pass in a Service objecté)Ú
stacklevelz[capabilities and desired_capabilities have been deprecated, please pass in a Service objectzCfirefox_binary has been deprecated, please pass in a Service objectNzEfirefox_profile has been deprecated, please pass in an Options objectz=log_path has been deprecated, please pass in a Service objectzEservice_log_path has been deprecated, please pass in a Service objectzAservice_args has been deprecated, please pass in a Service objectÚbinaryZacceptInsecureCertsF)Ú service_argsÚlog_path)Zremote_server_addrZ ignore_proxyT)Zcommand_executorÚoptionsÚ
keep_alive)r ÚwarningsÚwarnÚDeprecationWarningrÚprofileÚDEFAULT_LOG_PATHÚDEFAULT_SERVICE_LOG_PATHÚservicerZFIREFOXÚcopyr ÚdictÚgetÚ
isinstanceÚstrr    r
Zaccept_insecure_certsrrÚget_pathÚpathÚstartr Z service_urlZ_ignore_local_proxyÚsuperÚ__init__Z
_is_remote)ÚselfÚfirefox_profileÚfirefox_binaryZ capabilitiesÚproxyZexecutable_pathrZservice_log_pathrrZdesired_capabilitiesrrÚexecutor©Ú    __class__©ú[d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\selenium/webdriver/firefox/webdriver.pyr(0s¢Aÿýÿýÿýÿ
 
 
 
ÿzWebDriver.__init__cs„ztƒ ¡Wntk
r"YnX|j ¡|jrxz$t|jjƒ|jjrVt|jjƒWntk
rvt     
d¡YnX|  ¡dS)z3Quits the driver and close every associated window.z(Unable to remove profile specific paths.N) r'ÚquitÚ    ExceptionrÚstoprrr%Z
tempfolderÚloggerÚ    exceptionÚ_close_binary_file_handle©r)r.r0r1r2Ís
 zWebDriver.quitcCsNz*t|jtƒr(t|jjdƒr(|jj ¡Wntk
rHt d¡YnXdS)zèAttempts to close the underlying file handles for `FirefoxBinary`
        instances if they are used and open.
 
        To keep inline with other cleanup raising here is swallowed and
        will not cause a runtime error.
        Úclosez=Unable to close open file handle for firefox binary log file.N)    r"rr    ÚhasattrZ    _log_filer9r3r5r6r8r0r0r1r7ás  z#WebDriver._close_binary_file_handlecCs|jS)N)rr8r0r0r1r*ïszWebDriver.firefox_profilecCs| dd|i¡dS)NZ SET_CONTEXTÚcontext©Úexecute)r)r;r0r0r1Ú set_contextõszWebDriver.set_contextc    cs6| d¡ d¡}| |¡z
dVW5| |¡XdS)aàSets the context that Selenium commands are running in using a
        `with` statement. The state of the context on the server is saved
        before entering the block, and restored upon exiting it.
 
        :param context: Context, may be one of the class properties
            `CONTEXT_CHROME` or `CONTEXT_CONTENT`.
 
        Usage example::
 
            with selenium.context(selenium.CONTEXT_CHROME):
                # chrome scope
                ... do stuff ...
        Z GET_CONTEXTÚvalueN)r=Úpopr>)r)r;Zinitial_contextr0r0r1r;øs
 
 
zWebDriver.contextFc    CsÖtj |¡r’tƒ}t|ƒd}t |dtj¡H}t |¡D]6\}}}|D]&}    tj     ||    ¡}
| 
|
|
|d…¡qHq:W5QRXt   |  ¡¡ d¡} n*t|dƒ} t   |  ¡¡ d¡} W5QRX| |dœ} | d| ¡dS)    a’Installs Firefox addon.
 
        Returns identifier of installed addon. This identifier can later
        be used to uninstall addon.
 
        :param temporary: allows you to load browser extensions temporarily during a session
        :param path: Absolute path to the addon that will be installed.
 
        :Usage:
            ::
 
                driver.install_addon('/path/to/firebug.xpi')
        rÚwNzUTF-8Úrb)ÚaddonÚ    temporaryZ INSTALL_ADDONr?)Úosr%ÚisdirrÚlenÚzipfileÚZipFileÚ ZIP_DEFLATEDÚwalkÚjoinÚwriteÚbase64Ú    b64encodeÚgetvalueÚdecodeÚopenÚreadr=)r)r%rDÚfpZ    path_rootZzippedÚbaseÚdirsÚfilesZfyleÚfilenamerCÚfileÚpayloadr0r0r1Ú install_addons  " 
zWebDriver.install_addoncCs| dd|i¡dS)zUninstalls Firefox addon using its identifier.
 
        :Usage:
            ::
 
                driver.uninstall_addon('addon@foo.com')
        ZUNINSTALL_ADDONÚidNr<)r)Ú
identifierr0r0r1Úuninstall_addon-szWebDriver.uninstall_addonc    Csp| ¡ d¡st dt¡| ¡}zDz$t|dƒ}| |¡W5QRXWntk
rbYW¢
dSXW5~XdS)a¼Saves a full document screenshot of the current window to a PNG
        image file. Returns False if there is any IOError, else returns True.
        Use full paths in your filename.
 
        :Args:
         - filename: The full path you wish to save your screenshot to. This
           should end with a `.png` extension.
 
        :Usage:
            ::
 
                driver.get_full_page_screenshot_as_file('/Screenshots/foo.png')
        z.pngz^name used for saved screenshot does not match file type. It should end with a `.png` extensionÚwbFT)    ÚlowerÚendswithrrÚ UserWarningÚget_full_page_screenshot_as_pngrRrMÚOSError)r)rXZpngÚfr0r0r1Ú get_full_page_screenshot_as_file7sþ z*WebDriver.get_full_page_screenshot_as_filecCs
| |¡S)aµSaves a full document screenshot of the current window to a PNG
        image file. Returns False if there is any IOError, else returns True.
        Use full paths in your filename.
 
        :Args:
         - filename: The full path you wish to save your screenshot to. This
           should end with a `.png` extension.
 
        :Usage:
            ::
 
                driver.save_full_page_screenshot('/Screenshots/foo.png')
        )rf)r)rXr0r0r1Úsave_full_page_screenshotTsz#WebDriver.save_full_page_screenshotcCst | ¡ d¡¡S)z´Gets the full document screenshot of the current window as a binary
        data.
 
        :Usage:
            ::
 
                driver.get_full_page_screenshot_as_png()
        Úascii)rNÚ    b64decodeÚ"get_full_page_screenshot_as_base64Úencoder8r0r0r1rcds    z)WebDriver.get_full_page_screenshot_as_pngcCs| d¡dS)zìGets the full document screenshot of the current window as a base64
        encoded string which is useful in embedded images in HTML.
 
        :Usage:
            ::
 
                driver.get_full_page_screenshot_as_base64()
        ZFULL_PAGE_SCREENSHOTr?r<r8r0r0r1rjos    z,WebDriver.get_full_page_screenshot_as_base64)F)Ú__name__Ú
__module__Ú __qualname__ZCONTEXT_CHROMEZCONTEXT_CONTENTr rrr(r2r7Úpropertyr*r>rr;r#r[r^ÚboolrfrgÚbytesrcrjÚ __classcell__r0r0r.r1r,s>óò
 
 
 r)"rNÚloggingrErrHÚ
contextlibrÚiorÚshutilrZ.selenium.webdriver.common.desired_capabilitiesrZ'selenium.webdriver.common.driver_finderrZ#selenium.webdriver.remote.webdriverrZRemoteWebDriverr+r    r*r
rr Zremote_connectionr rr rÚ    getLoggerrlr5rrr0r0r0r1Ú<module>s(