a
    7ñ»jP ã                   @   sˆ   d Z ddlZddlZddlmZ ddlmZ ddlmZ	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ G dd„ deƒZdS )zGSelenium Plugin for SeleniumBase tests that run with pynose / nosetestsé    N)Úsuppress)ÚPlugin)Úconfig)Úsettings)Údetect_b_ver)Úproxy_helper)Ú	constants)Úshared_utilsc                       sH   e Zd ZdZdZ‡ fdd„Z‡ fdd„Zdd„ Zd	d
„ Zdd„ Z	‡  Z
S )ÚSeleniumBrowseraÿ  This plugin adds the following command-line options to pynose:
    --browser=BROWSER  (The web browser to use. Default: "chrome".)
    --chrome  (Shortcut for "--browser=chrome". Default.)
    --edge  (Shortcut for "--browser=edge".)
    --firefox  (Shortcut for "--browser=firefox".)
    --safari  (Shortcut for "--browser=safari".)
    --opera  (Shortcut for "--browser=opera".)
    --brave  (Shortcut for "--browser=brave".)
    --comet  (Shortcut for "--browser=comet".)
    --atlas  (Shortcut for "--browser=atlas".)
    --use-chromium  (Shortcut for using base `Chromium`)
    --cft  (Shortcut for using `Chrome for Testing`)
    --chs  (Shortcut for using `Chrome-Headless-Shell`)
    --user-data-dir=DIR  (Set the Chrome user data directory to use.)
    --protocol=PROTOCOL  (The Selenium Grid protocol: http|https.)
    --server=SERVER  (The Selenium Grid server/IP used for tests.)
    --port=PORT  (The Selenium Grid port used by the test server.)
    --cap-file=FILE  (The web browser's desired capabilities to use.)
    --cap-string=STRING  (The web browser's desired capabilities to use.)
    --proxy=SERVER:PORT  (Connect to a proxy server:port as tests are running)
    --proxy=USERNAME:PASSWORD@SERVER:PORT  (Use an authenticated proxy server)
    --proxy-bypass-list=STRING (";"-separated hosts to bypass, Eg "*.foo.com")
    --proxy-pac-url=URL  (Connect to a proxy server using a PAC_URL.pac file.)
    --proxy-pac-url=USERNAME:PASSWORD@URL  (Authenticated proxy with PAC URL.)
    --proxy-driver  (If a driver download is needed, will use: --proxy=PROXY.)
    --multi-proxy  (Allow multiple authenticated proxies when multi-threaded.)
    --agent=STRING  (Modify the web browser's User-Agent string.)
    --mobile  (Use the mobile device emulator while running tests.)
    --metrics=STRING  (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)
    --chromium-arg="ARG=N,ARG2" (Set Chromium args, ","-separated, no spaces.)
    --firefox-arg="ARG=N,ARG2" (Set Firefox args, comma-separated, no spaces.)
    --firefox-pref=SET  (Set a Firefox preference:value set, comma-separated.)
    --extension-zip=ZIP  (Load a Chrome Extension .zip|.crx, comma-separated.)
    --extension-dir=DIR  (Load a Chrome Extension directory, comma-separated.)
    --disable-features="F1,F2" (Disable features, comma-separated, no spaces.)
    --binary-location=PATH  (Set path of the Chromium browser binary to use.)
    --driver-version=VER  (Set the chromedriver or uc_driver version to use.)
    --sjw  (Skip JS Waits for readyState to be "complete" or Angular to load.)
    --wfa  (Wait for AngularJS to be done loading after specific web actions.)
    --pls=PLS  (Set pageLoadStrategy on Chrome: "normal", "eager", or "none".)
    --headless  (The default headless mode. Linux uses this mode by default.)
    --headless1  (Use Chrome's old headless mode. Fast, but has limitations.)
    --headless2  (Use Chrome's new headless mode, which supports extensions.)
    --headed  (Run tests in headed/GUI mode on Linux OS, where not default.)
    --xvfb  (Run tests using the Xvfb virtual display server on Linux OS.)
    --xvfb-metrics=STRING  (Set Xvfb display size on Linux: "Width,Height".)
    --locale=LOCALE_CODE  (Set the Language Locale Code for the web browser.)
    --interval=SECONDS  (The autoplay interval for presentations & tour steps)
    --start-page=URL  (The starting URL for the web browser when tests begin.)
    --time-limit=SECONDS  (Safely fail any test that exceeds the time limit.)
    --slow  (Slow down the automation. Faster than using Demo Mode.)
    --demo  (Slow down and visually see test actions as they occur.)
    --demo-sleep=SECONDS  (Set the wait time after Slow & Demo Mode actions.)
    --highlights=NUM  (Number of highlight animations for Demo Mode actions.)
    --message-duration=SECONDS  (The time length for Messenger alerts.)
    --check-js  (Check for JavaScript errors after page loads.)
    --ad-block  (Block some types of display ads from loading.)
    --host-resolver-rules=RULES  (Set host-resolver-rules, comma-separated.)
    --block-images  (Block images from loading during tests.)
    --do-not-track  (Indicate to websites that you don't want to be tracked.)
    --verify-delay=SECONDS  (The delay before MasterQA verification checks.)
    --ee / --esc-end  (Lets the user end the current test via the ESC key.)
    --recorder  (Enables the Recorder for turning browser actions into code.)
    --rec-behave  (Same as Recorder Mode, but also generates behave-gherkin.)
    --rec-sleep  (If the Recorder is enabled, also records self.sleep calls.)
    --rec-print  (If the Recorder is enabled, prints output after tests end.)
    --disable-cookies  (Disable Cookies on websites. Pages might break!)
    --disable-js  (Disable JavaScript on websites. Pages might break!)
    --disable-csp  (Disable the Content Security Policy of websites.)
    --disable-ws  (Disable Web Security on Chromium-based browsers.)
    --enable-ws  (Enable Web Security on Chromium-based browsers.)
    --enable-sync  (Enable "Chrome Sync" on websites.)
    --uc | --undetected  (Use undetected-chromedriver to evade bot-detection.)
    --uc-cdp-events  (Capture CDP events when running in "--undetected" mode.)
    --log-cdp  ("goog:loggingPrefs", {"performance": "ALL", "browser": "ALL"})
    --remote-debug  (Sync to Chrome Remote Debugger chrome://inspect/#devices)
    --enable-3d-apis  (Enables WebGL and 3D APIs.)
    --swiftshader  (Chrome "--use-gl=angle" / "--use-angle=swiftshader-webgl")
    --incognito  (Enable Chrome's Incognito mode.)
    --guest  (Enable Chrome's Guest mode.)
    --dark  (Enable Chrome's Dark mode.)
    --devtools  (Open Chrome's DevTools when the browser opens.)
    --disable-beforeunload  (Disable the "beforeunload" event on Chrome.)
    --window-position=X,Y  (Set the browser's starting window position.)
    --window-size=WIDTH,HEIGHT  (Set the browser's starting window size.)
    --maximize  (Start tests with the browser window maximized.)
    --screenshot  (Save a screenshot at the end of each test.)
    --visual-baseline  (Set the visual baseline for Visual/Layout tests.)
    --wire  (Use selenium-wire's webdriver for replacing selenium webdriver.)
    --external-pdf (Set Chromium "plugins.always_open_pdf_externally": True.)
    --timeout-multiplier=MULTIPLIER  (Multiplies the default timeout values.)
    Zseleniumc                    s®	  t ƒ j||d� |j|_|jdddtjjtjjdd� |jddd	d
dd� |jdddd
dd� |jdddd
dd� |jdddd
dd� |jdddd
dd� |jdddd
dd� |jdddd
dd� |jddd d
d!d� |jd"dd#d
d$d� |jd%dd&d
d'd� |jd(dd)d
d*d� |jd+dd,d
d-d� |jd.d/dd0d d1d� |jd2d3d4d d5d6� |jd7d8dd9d d:d� |jd;d<d=dd>d
d?d� |jd@dAdBddCd
dDd� |jdEddFtj	j
tj	jftj	j
dGd� |jdHddIdJdKd� |jdLddMdNdOd� |jdPdQdRddSd dTd� |jdUdVddWd dXd� |jdYdZdd[d d\d� |jd]d^dd_d
d`d� |jdadbddcd
ddd� |jdedfdgddhd did� |jdjdkdlddmd
dnd� |jdodpdqddrd dsd� |jdtduddvd dwd� |jdxdyddzd d{d� |jd|d}dd~d dd� |jd€d�d‚ddƒd d„d� |jd…d†dd‡d dˆd� |jd‰dŠdd‹d dŒd� |jd�dŽd�dd�d d‘d� |jd’d“dd”d d•d� |jd–d—d˜dd™tjjtjjtjjfd dšd� |jd›ddœd
d�d� |jdžddŸd
d d� |jd¡dd¢d
d£d� |jd¤d¥dd¦d
d§d� |jd¨dd©d
dªd� |jd«d¬dd­d d®d� |jd¯d°d±dd²d d³d� |jd´ddµd d¶d� |jd·d¸d¹ddºd d»d� |jd¼d½d¾dd¿d dÀd� |jdÁdÂdÃdÄddÅd
dÆd� |jdÇdÈdÉddÊd
dËd� |jdÌdÍddÎd dÏd� |jdÐddÑd dÒd� |jdÓdÔddÕd dÖd� |jd×dØddÙd
dÚd� |jdÛdÜdÝdÞdßddàd
dád�	 |jdâdãddäd dåd� |jdædçddèd
déd� |jdêdëddìd
díd� |jdîdïddðd dñd� |jdòdódôddõd
död� |jd÷dødùdúddûd
düd� |jdýdþddÿd
�d d� |j�d�dd�dd
�dd� |j�dd�dd
�dd� |j�d�d	d�d
d
�dd� |j�d�dd�dd
�dd� |j�d�d�d�d�dd�dd
�dd�	 |j�d�d�d�dd�dd
�dd� |j�d�d�dd�d d
�d!d� |j�d"�d#d�d$d
�d%d� |j�d&�d'�d(d�d)d
�d*d� |j�d+�d,�d-d�d.d
�d/d� |j�d0�d1�d2d�d3d �d4d� |j�d5�d6�d7d�d8d �d9d� |j�d:�d;d�d<d
�d=d� |j�d>�d?d�d@d
�dAd� |j�dB�dC�dD�dEd�dFd �dGd� |j�dH�dI�dJ�dKd�dLd
�dMd� |j�dN�dOd�dPd
�dQd� |j�dRd�dSd
�dTd� |j�dU�dV�dWd�dXd
�dYd� |j�dZ�d[�d\d�d]d
�d^d� |j�d_�d`�dad�dbd
�dcd� |j�dd�de�dfd�dgd
�dhd� |j�di�djd�dkd
�dld� |j�dm�dnd�dod �dpd� |j�dq�drd�dsd �dtd� |j�du�dv�dw�dxd�dyd
�dzd� |j�d{�d|�d}�d~d�dd
�d€d� |j�d��d‚�dƒd�d„d
�d…d� |j�d†�d‡d�dˆd
�d‰d� |j�dŠd�d‹d
�dŒd� |j�d��dŽd�d�d
�d�d� |j�d‘�d’d�d“d �d”d� d S (•  N)Úenvz	--browserÚstoreÚbrowserzvSpecifies the web browser to use. Default: Chrome.
                    Examples: (--browser=edge OR --browser=firefox))ÚactionÚdestÚchoicesÚdefaultÚhelpú--chromeÚ
store_trueZ
use_chromeFz'Shortcut for --browser=chrome (Default))r   r   r   r   ú--edgeZuse_edgezShortcut for --browser=edgeú	--firefoxZuse_firefoxzShortcut for --browser=firefoxú--ieZuse_iezShortcut for --browser=ieú--safariZ
use_safarizShortcut for --browser=safariú--operaZ	use_operazShortcut for --browser=operaú--braveZ	use_bravezShortcut for --browser=braveú--cometZ	use_cometzShortcut for --browser=cometú--atlasZ	use_atlaszShortcut for --browser=atlasz--use-chromiumÚuse_chromiumz"Shortcut for using base `Chromium`z--cftÚuse_cftz'Shortcut for using `Chrome for Testing`z--chsÚuse_chsz*Shortcut for using `Chrome-Headless-Shell`z
--cap_filez
--cap-fileÚcap_filezsThe file that stores browser desired capabilities
                    for BrowserStack, Sauce Labs, or other grids.z--cap_stringz--cap-stringÚ
cap_stringa1  The string that stores browser desired capabilities
                    for BrowserStack, Sauce Labs, or other grids.
                    Enclose cap-string in single quotes.
                    Enclose parameter keys in double quotes.
                    Example: --cap-string='{"name":"test1","v":"42"}')r   r   r   z--user_data_dirz--user-data-dirÚuser_data_dirz}The Chrome User Data Directory to use. (Chrome Profile)
                    If the directory doesn't exist, it'll be created.z--sjwz--skip_js_waitsz--skip-js-waitsÚskip_js_waitszºSkip all calls to wait_for_ready_state_complete()
                    and wait_for_angularjs(), which are part of many
                    SeleniumBase methods for improving reliability.z--wfaz--wait_for_angularjsz--wait-for-angularjsÚwait_for_angularjsz³Add waiting for AngularJS. (The default setting
                    was changed to no longer wait for AngularJS to
                    finish loading as an extra JavaScript call.)z
--protocolÚprotocolzPDesignates the Selenium Grid protocol to use.
                    Default: http.z--serverÚ
servernameÚ	localhostzÞDesignates the Selenium Grid server to use.
                    Use "127.0.0.1" to connect to a localhost Grid.
                    If unset or set to "localhost", Grid isn't used.
                    Default: "localhost".z--portÚportZ4444zoDesignates the Selenium Grid port to use.
                    Default: 4444. (If 443, protocol becomes "https")z--proxyz--proxy-serverz--proxy-stringÚproxy_stringa   Designates the proxy server:port to use.
                    Format: servername:port.  OR
                            username:password@servername:port  OR
                            A dict key from proxy_list.PROXY_LIST
                    Default: None.z--proxy-bypass-listz--proxy_bypass_listÚproxy_bypass_lista8  Designates the hosts, domains, and/or IP addresses
                    to bypass when using a proxy server with "--proxy".
                    Format: A ";"-separated string.
                    Example usage:
                        pytest
                            --proxy="username:password@servername:port"
                            --proxy-bypass-list="*.foo.com;github.com"
                        pytest
                            --proxy="servername:port"
                            --proxy-bypass-list="127.0.0.1:8080"
                    Default: None.z--proxy-pac-urlz	--pac-urlÚproxy_pac_urlz¯Designates the proxy PAC URL to use.
                    Format: A URL string  OR
                            A username:password@URL string
                    Default: None.z--proxy-driverz--proxy_driverÚproxy_driverzhIf a driver download is needed for tests,
                    uses proxy settings set via --proxy=PROXY.z--multi-proxyz--multi_proxyÚmulti_proxyz­If you need to run multi-threaded tests with
                    multiple proxies that require authentication,
                    set this to allow multiple configurations.z--agentz--user-agentz--user_agentÚ
user_agentzzDesignates the User-Agent for the browser to use.
                    Format: A string.
                    Default: None.z--mobilez--mobile-emulatorz--mobile_emulatorÚmobile_emulatorzdIf this option is enabled, the mobile emulator
                    will be used while running tests.z	--metricsz--device-metricsz--device_metricsÚdevice_metricsaL  Designates the three device metrics of the mobile
                    emulator: CSS Width, CSS Height, and Pixel-Ratio.
                    Format: A comma-separated string with the 3 values.
                    Examples: "375,734,5" or "412,732,3" or "390,715,3"
                    Default: None. (Will use default values if None)z--chromium_argz--chromium-argÚchromium_arga"  Add a Chromium argument for Chrome/Edge browsers.
                    Format: A comma-separated list of Chromium args.
                    If an arg doesn't start with "--", that will be
                    added to the beginning of the arg automatically.
                    Default: None.z--firefox_argz--firefox-argÚfirefox_arga   Add a Firefox argument for Firefox browser runs.
                    Format: A comma-separated list of Firefox args.
                    If an arg doesn't start with "--", that will be
                    added to the beginning of the arg automatically.
                    Default: None.z--firefox_prefz--firefox-prefÚfirefox_prefa]  Set a Firefox preference:value combination.
                    Format: A comma-separated list of pref:value items.
                    Example usage:
                        --firefox-pref="browser.formfill.enable:True"
                        --firefox-pref="pdfjs.disabled:False"
                        --firefox-pref="abc.def.xyz:42,hello.world:text"
                    Boolean and integer values to the right of the ":"
                    will be automatically converted into proper format.
                    If there's no ":" in the string, then True is used.
                    Default: None.z--extension_zipz--extension-zipz--crxÚextension_zipzÛDesignates the Chrome Extension ZIP file to load.
                    Format: A comma-separated list of .zip or .crx files
                    containing the Chrome extensions to load.
                    Default: None.z--extension_dirz--extension-dirÚextension_dirzäDesignates the Chrome Extension folder to load.
                    Format: A directory containing the Chrome extension.
                    (Can also be a comma-separated list of directories.)
                    Default: None.z--disable_featuresz--disable-featuresÚdisable_featuresz Disable Chromium features from Chrome/Edge browsers.
                    Format: A comma-separated list of Chromium features.
                    Default: None.ú--binary_locationú--binary-locationú--blÚbinary_locationz~Sets the path of the Chromium browser binary to use.
                    Uses the default location if not os.path.exists(PATH)z--driver_versionz--driver-versionÚdriver_versiona  Setting this overrides the default driver version,
                    which is set to match the detected browser version.
                    Major version only. Example: "--driver-version=114"
                    (Only chromedriver and uc_driver are affected.)z--plsz--page_load_strategyz--page-load-strategyÚpage_load_strategyzkThis option sets Chrome's pageLoadStrategy.
                    List of choices: "normal", "eager", "none".z
--headlessÚheadlesszÙUsing this option activates headless mode,
                which is required on headless machines
                UNLESS using a virtual display with Xvfb.
                Default: False on Mac/Windows. True on Linux.z--headless1Ú	headless1z§This option activates the old headless mode,
                    which is faster, but has limitations.
                    (May be phased out by Chrome in the future.)z--headless2Ú	headless2z±This option activates the new headless mode,
                    which supports Chromium extensions, and more,
                    but is slower than the standard headless mode.z--headedz--guiÚheadedz÷Using this makes Webdriver run web browsers with
                    a GUI when running tests on Linux machines.
                    (The default setting on Linux is headless.)
                    (The default setting on Mac or Windows is headed.)z--xvfbÚxvfba+  Using this makes tests run headlessly using Xvfb
                    instead of the browser's built-in headless mode.
                    When using "--xvfb", the "--headless" option
                    will no longer be enabled by default on Linux.
                    Default: False. (Linux-ONLY!)z--xvfb-metricsz--xvfb_metricsÚxvfb_metricsa
  Customize the Xvfb metrics (Width,Height) on Linux.
                    Format: A comma-separated string with the 2 values.
                    Examples: "1920,1080" or "1366,768" or "1024,768".
                    Default: None. (None: "1366,768". Min: "1024,768".)z--locale_codez--locale-codez--localeÚlocale_codeaP  Designates the Locale Code for the web browser.
                    A Locale is a specific version of a spoken Language.
                    The Locale alters visible text on supported websites.
                    See: https://seleniumbase.io/help_docs/locale_codes/
                    Default: None. (The web browser's default mode.)z
--intervalÚintervala<  This globally overrides the default interval,
                    (in seconds), of features that include autoplay
                    functionality, such as tours and presentations.
                    Overrides from methods take priority over this.
                    (Headless Mode skips tours and presentations.)z--start_pagez--start-pagez--urlÚ
start_pagez}Designates the starting URL for the web browser
                    when each test begins.
                    Default: None.z--time_limitz--time-limitz--timelimitÚ
time_limitzqUse this to set a time limit per test, in seconds.
                    If a test runs beyond the limit, it fails.z--slow_modez--slow-modez--slowmoz--slowÚ	slow_modez%Using this slows down the automation.z--demo_modez--demo-modez--demoÚ	demo_modezuUsing this slows down the automation and lets you
                    visually see what the tests are actually doing.z--demo_sleepz--demo-sleepÚ
demo_sleepzgSetting this overrides the Demo Mode sleep
                    time that happens after browser actions.z--highlightsÚ
highlightszlSetting this overrides the default number of
                    highlight animation loops to have per call.z--message_durationz--message-durationÚmessage_durationz­Setting this overrides the default time that
                    messenger notifications remain visible when
                    reaching assert statements during Demo Mode.z
--check_jsz
--check-jsÚjs_checking_onzTThe option to check for JavaScript errors after
                    every page load.z	--adblockz
--ad_blockz
--ad-blockz--block_adsz--block-adsÚad_block_onzqUsing this makes WebDriver block display ads
                    that are defined in ad_block_list.AD_BLOCK_LIST.z--host_resolver_rulesz--host-resolver-rulesÚhost_resolver_rulesa¿  Use this option to set "host-resolver-rules".
                    This lets you re-map traffic from any domain.
                    Eg. "MAP www.google-analytics.com 0.0.0.0".
                    Eg. "MAP * ~NOTFOUND , EXCLUDE myproxy".
                    Eg. "MAP * 0.0.0.0 , EXCLUDE 127.0.0.1".
                    Eg. "MAP *.google.com myproxy".
                    Find more examples on these pages:
                    (https://www.electronjs.org/docs/
                     latest/api/command-line-switches)
                    (https://www.chromium.org/developers/
                     design-documents/network-stack/socks-proxy/)
                    Use comma-separation for multiple host rules.z--block_imagesz--block-imagesÚblock_imageszcUsing this makes WebDriver block images from
                    loading on web pages during tests.z--do_not_trackz--do-not-trackÚdo_not_trackzñIndicate to websites that you don't want to be
                    tracked. The browser will send an extra HTTP
                    header each time it requests a web page.
                    https://support.google.com/chrome/answer/2790761z--verify_delayz--verify-delayÚverify_delayzjSetting this overrides the default wait time
                    before each MasterQA verification pop-up.z	--esc-endz	--esc_endz--eeÚesc_endzcEnd the current test early via the ESC key.
                    The test will be marked as skipped.z
--recorderz--recordz--recz	--codegenÚrecorder_modez�Using this enables the SeleniumBase Recorder,
                    which records browser actions for converting
                    into SeleniumBase scripts.z--rec-behavez--rec-gherkinÚ
rec_behavea  Not only enables the SeleniumBase Recorder,
                    but also saves recorded actions into the
                    behave-gerkin format, which includes a
                    feature file, an imported steps file,
                    and the environment.py file.z--rec-sleepz--record-sleepÚrecord_sleepzNIf Recorder Mode is enabled,
                    records sleep(seconds) calls.z--rec-printÚ	rec_printzOIf Recorder Mode is enabled,
                    prints output after tests end.z--disable_jsz--disable-jsÚ
disable_jszmThe option to disable JavaScript on web pages.
                    Warning: Most web pages will stop working!z--disable_cookiesz--disable-cookiesÚdisable_cookieszhThe option to disable Cookies on web pages.
                    Warning: Several pages may stop working!z--disable_cspz--disable-cspz--no_cspz--no-cspz--dcspÚdisable_cspa�  Using this disables the Content Security Policy of
                    websites, which may interfere with some features of
                    SeleniumBase, such as loading custom JavaScript
                    libraries for various testing actions.
                    Setting this to True (--disable-csp) overrides the
                    value set in seleniumbase/config/settings.pyz--disable_wsz--disable-wsz--dwsz--disable-web-securityÚ
disable_wszvUsing this disables the "Web Security" feature of
                    Chrome and Chromium-based browsers such as Edge.z--enable_wsz--enable-wsz--enable-web-securityÚ	enable_wszuUsing this enables the "Web Security" feature of
                    Chrome and Chromium-based browsers such as Edge.z--enable_syncz--enable-syncÚenable_syncz-Using this enables the "Chrome Sync" feature.z--use_auto_extz--use-auto-extz
--auto-extÚuse_auto_extz�(DEPRECATED) - Enable the automation extension.
                    It's not required, but some commands & advanced
                    features may need it.z--undetectedz--undetectablez--ucÚundetectablez·Using this option makes chromedriver undetectable
                    to websites that use anti-bot services to block
                    automation tools from navigating them freely.z--uc_cdp_eventsz--uc-cdp-eventsz--uc-cdpÚuc_cdp_eventsa¬  Captures CDP events during Undetectable Mode runs.
                    Then you can add a listener to perform actions on
                    received data, such as printing it to the console:
                        from pprint import pformat
                        self.driver.add_cdp_listener(
                            "*", lambda data: print(pformat(data))
                        )
                        self.open(URL)z--uc_subprocessz--uc-subprocessz--uc-subÚuc_subprocessz´(DEPRECATED) - (UC Mode always uses this now.)
                    Use undetectable-chromedriver as a subprocess,
                    which can help avoid issues that might result.z--no_sandboxz--no-sandboxÚ
no_sandboxz·(DEPRECATED) - "--no-sandbox" is always used now.
                    Using this enables the "No Sandbox" feature.
                    (This setting is now always enabled by default.)z--disable_gpuz--disable-gpuÚdisable_gpuz¸(DEPRECATED) - GPU is disabled if no swiftshader.
                    Using this enables the "Disable GPU" feature.
                    (GPU is disabled by default if swiftshader off.)z	--log_cdpz	--log-cdpz--log_cdp_eventsz--log-cdp-eventsÚlog_cdp_eventsziCapture CDP events. Then you can print them.
                    Eg. print(driver.get_log("performance"))z--remote_debugz--remote-debugz--remote-debuggerz--remote_debuggerÚremote_debugaK  This syncs the browser to Chromium's remote debugger.
                    To access the remote debugging interface, go to:
                    chrome://inspect/#devices while tests are running.
                    The previous URL was at: http://localhost:9222/
                    Info: chromedevtools.github.io/devtools-protocol/z--enable_3d_apisz--enable-3d-apisÚenable_3d_apisz%Using this enables WebGL and 3D APIs.z--swiftshaderÚswiftshaderzgUsing this enables the "--use-gl=swiftshader"
                    feature when running tests on Chrome.z--incognitoz--incognito_modez--incognito-modeÚ	incognitoz+Using this enables Chrome's Incognito mode.z--guestz--guest_modez--guest-modeÚ
guest_modez'Using this enables Chrome's Guest mode.z--darkz--dark_modez--dark-modeÚ	dark_modez&Using this enables Chrome's Dark mode.z
--devtoolsz--open_devtoolsz--open-devtoolsÚdevtoolsz#Using this opens Chrome's DevTools.z--disable-beforeunloadz--disable_beforeunloadÚ_disable_beforeunloadz©The option to disable the "beforeunload" event
                    on Chromium browsers (Chrome or Edge).
                    This is already the default Firefox option.z--window-positionz--window_positionÚwindow_positionzåThe option to set the starting window x,y position.
                    Format: A comma-separated string with the 2 values.
                    Example: "55,66"
                    Default: None. (Will use default values if None)z--window-sizez--window_sizeÚwindow_sizezéThe option to set the default window "width,height".
                    Format: A comma-separated string with the 2 values.
                    Example: "1200,800"
                    Default: None. (Will use default values if None)z--maximize_windowz--maximize-windowz
--maximizez--fullscreenÚmaximize_optionzvThe option to start with a maximized browser window.
                    (Overrides the "window-size" option if used.)z--screenshotz--save_screenshotz--save-screenshotz--ssÚsave_screenshotz«Save a screenshot at the end of every test.
                    By default, this is only done for failures.
                    Will be saved in the "latest_logs/" folder.z--no-screenshotz--no_screenshotz--nsÚno_screenshotz¿No screenshots saved unless tests directly ask it.
                    This changes default behavior where screenshots are
                    saved for test failures and pytest-html reports.z--visual_baselinez--visual-baselineÚvisual_baselinezóSetting this resets the visual baseline for
                    Automated Visual Testing with SeleniumBase.
                    When a test calls self.check_window(), it will
                    rebuild its files in the visual_baseline folder.z--wireÚuse_wirez5Use selenium-wire's webdriver for selenium webdriver.z--external_pdfz--external-pdfÚexternal_pdfzûThis option sets the following on Chromium:
                    "plugins.always_open_pdf_externally": True,
                    which causes opened PDF URLs to download immediately,
                    instead of being displayed in the browser window.z--timeout_multiplierz--timeout-multiplierÚtimeout_multiplierz²Setting this overrides the default timeout
                    by the multiplier when waiting for page elements.
                    Unused when tests override the default value.)ÚsuperÚoptionsÚ
add_optionZ	addoptionr   ZValidBrowsersZvalid_browsersZBrowserZGOOGLE_CHROMEÚProtocolÚHTTPZHTTPSZPageLoadStrategyZNORMALZEAGERÚNONE)ÚselfÚparserr   ©Ú	__class__© úJE:\soccer\ml_env\Lib\site-packages\seleniumbase/plugins/selenium_plugin.pyrv   m   s   ú	ûûûûûûûûûûûûú	ûú	ùùþ÷û
ûùúúú	ú
ùù
ùúúúùúú
ù
úýôû
û	û	úûúùûùù
ø
ù
ú	ûú
ú	÷úú	úú	ù
øúú	ûú	ú	÷øù
úùùùùú
ú
øøúûù	ù	ù	ù	ú
úúøøùúûúúzSeleniumBrowser.optionsc                    s8   t ƒ  ||¡ d| _|| _d| _dt_dt_t ¡  d S )NTF)	ru   Ú	configureÚenabledrv   Úheadless_activeÚ	sb_configÚis_nosetestr   Úremove_proxy_zip_if_present)r{   rv   Zconfr}   r   r€   r�   7  s    zSeleniumBrowser.configurec                 C   s`  | j j}||j_d |j_d |j_d |j_d t_tj	}d}d }d }g }d}|D ]}	|	dv rLd}qLd|v snd|v r„|d7 }d}| 
d¡ d	|v s”d
|v rª|d7 }d}| 
d	¡ d|v sºd|v rÐ|d7 }d}| 
d¡ d|v sàd|v rö|d7 }d}| 
d¡ d|v �s
d|v �r |d7 }d}| 
d¡ d|v �s4d|v �rJ|d7 }d}| 
d¡ d|v �s^d|v �r¤|�s¤t d¡}
tj |
¡�r¤|d7 }d}dt_dt_|
t_| 
d¡ d|v �s¸d|v �rþ|�sþt d¡}
tj |
¡�rþ|d7 }d}dt_dt_|
t_| 
d¡ d|v �sd|v �rX|�sXt d ¡}
tj |
¡�rX|d7 }d }d t_d t_|
t_| 
d¡ d!|v �sld"|v �r²|�s²t d#¡}
tj |
¡�r²|d7 }d#}d#t_d#t_|
t_| 
d!¡ |}d$|v �ræ|dk�sæ|d7 }d}dt_| 
d$¡ d%|v �r|dk�s|d7 }d}dt_| 
d%¡ d&|v �rF|dk�sF|d7 }d}dt_| 
d&¡ d'|v �rv|dk�sv|d7 }d}dt_| 
d'¡ d(|v �r¦|dk�s¦|d7 }d}dt_| 
d(¡ d)|v �r |dk�s |�s t d¡}
tj |
¡�r |d7 }d}dt_dt_|
t_| 
d)¡ d*|v �rZ|dk�sZ|�sZt d¡}
tj |
¡�rZ|d7 }d}dt_dt_|
t_| 
d*¡ d+|v �r´|d k�s´|�s´t d ¡}
tj |
¡�r´|d7 }d }d t_d t_|
t_| 
d+¡ d,|v �r|d#k�s|�st d#¡}
tj |
¡�r|d7 }d#}d#t_d#t_|
t_| 
d,¡ |dk�rJd-}|d.|d/ |¡f 7 }|d07 }|d17 }t|ƒ‚|�rT|}| j j�rx|d2v�rxd3| }t|ƒ‚| j j}|�r| d4¡dk�r¦d5| }t|ƒ‚| d6d7¡}d }d }z(t| d4¡d ƒ}t| d4¡d ƒ}W n$ t�y   d8| }t|ƒ‚Y n0 |t_|t_| j j}|�r¼| d4¡dk�rBd9| }t|ƒ‚| d6d7¡}d }d }z(t| d4¡d ƒ}t| d4¡d ƒ}W n$ t�y¢   d:| }t|ƒ‚Y n0 |t_|t_|t_ |t_!d|j_"d|j_#d|j_$d|j_%dt_"dt_#dt_$dt_%| j j|j_tj�rtj| j _tj|j_| j j&|j_&| j j'|j_'| j j|j_| j j|j_|jj�r^d|j_| j j|j_|jj�r’|jjdk�r’d|j_d|j_|jj�rÌ|jjdk�rÌd|j_d|j_d| j _d| j _n|jjd;v�rêd|j_d| j _| j j(|j_(| j j)|j_)| j j*|j_*| j j+|j_+| j j,|j_,| j j-|j_-| j j.�rBdt_/| j j0�rRdt_1| j j2|j_2| j j3|j_3| j j4|j_4| j j5|j_5| j j6|j_6| j j7|j_7| j j8|j_8| j j9|j_9t:td<d ƒ�rÊtj|j_9| j j;�rè|jj9�sèd=|j_9n:| j j<�	r|jj9�	sd>|j_9n| j j=�	r"|jj9�	s"d?|j_9|jj9t_9|jj9�	rn|jj9 >¡ d?k�	rn|jjdk�	rnd|j_d|j_d|j_|jjt?j@jAv �	rštj9�	sšd|j_|jjt_| j jB|j_B| j jC|j_C| j jD|j_D| j jE|j_E| j jF|j_F| j jG|j_G| j jH|j_H| j jI|j_I| j jJ|j_J| j jK|j_K| j jL|j_L| j jM|j_M| j jN|j_N| j jO|j_O| j jP|j_P| j jQ|j_Q| j jR|j_R| j jS|j_S| j jT|j_T| j jU|j_U| j jV|j_V| j jW|j_W| j jX|j_X| j jY|j_Y| j jZ|j_Z| j j|j_| j j|j_[| j j\|j_\| j j]|j_]| j j^|j_^| j j]�rd|j_d|j_[n6| j j\�r:d|j_d|j_[n| j j^�rTd|j_d|j_[| j j_|j__| j j`|j_`| j ja|j_a| j jb|j_b| j jc|j_c| j jb�s¢d|j_c| j jd|j_d| j je|j_e| j jf|j_f| j jg|j_g| j jh|j_h|jjg�rú|jjf�súd|j_f| j ji|j_i|jji�r"|jjf�s"d|j_f| j jj|j_j| j jk|j_k| j jl|j_l| j jm|j_m| j jn|j_o| j jp|j_p| j jq|j_q| j jr|j_r| j js|j_s| j jt|j_t| j j|j_| j j|j_| j ju|j_u| j jv�rÚ| j jw�rÚd| j _v| j jv|j_x| j jw|j_y| j jz|j_z| j j{|j_{| j j||j_|| j j}|j_}d|j_~d|j_d|j_€|jjt_|jjyt_w|jj3d@k�rvt�| j j4ƒdAk�rvdB|j_2t‚ ƒ¡ �rÜ| j j(�sÜ| j j�sÜ| j j�sÜ| j j)�sÜ| j jf�sÌt„dCƒ d| j _d|j_nd| j _)d|j_)| j j{�r| j jf�rt„dDƒ d| j _{d|j_{| j j�rL| j j�rLd| j _d| j _d| j _d|j_d|j_d|j_| j j�sp| j j�spd| j _(d|j_(d t_…dt_†d| _†t‚ ƒ¡ �r| j j(�r | j j)�rtj }tj!}t‡tƒ�L ddElˆm‰} |d||fdF�| _Š| jŠ ‹¡  | jŠt_…d| _†dt_†W d   ƒ n1 �s0    Y  dt_Œtj�t_Žtj�t_�dt_‘| j jLt_L| j j’t_’| j jJt_Jd | _“| j“|j_“d S )GNr   F)r8   r7   r9   Tz--browser=chromez--browser chromeé   Úchromez--browser=edgez--browser edgeÚedgez--browser=firefoxz--browser firefoxZfirefoxz--browser=safariz--browser safariZsafariz--browser=iez--browser ieÚiez--browser=remotez--browser remoteÚremotez--browser=operaz--browser operaÚoperaz--browser=bravez--browser braveÚbravez--browser=cometz--browser cometÚcometz--browser=atlasz--browser atlasÚatlasr   r   r   r   r   r   r   r   r   z(

  TOO MANY browser types were entered!z
  There were %s found:
  >  %sz, z'
  ONLY ONE default browser is allowed!z(
  Select a single browser & try again!
)rˆ   r‰   rŒ   r�   rŽ   r�   ZchromiumzU

  Recorder Mode ONLY supports Chromium browsers!
  (Your browser choice was: "%s")
ú,zF

  window_position expects an "x,y" string!
  (Your input was: "%s")
ú Ú zL

  Expecting integer values for "x,y"!
  (window_position input was: "%s")
zJ

  window_size expects a "width,height" string!
  (Your input was: "%s")
zQ

  Expecting integer values for "width,height"!
  (window_size input was: "%s")
)rˆ   r‰   Ú_cdp_bin_locZ
_chromium_ZcftZchsr'   Ú443Úhttpsz­(Linux uses --headless by default. To override, use --headed / --gui. For Xvfb mode instead, use --xvfb. Or you can hide this info by using --headless / --headless2 / --uc.)zí
SeleniumBase doesn't support mixing --uc with --wire mode.
If you need both, override get_new_driver() from BaseCase:
https://seleniumbase.io/help_docs/syntax_formats/#sb_sf_09
(Only UC Mode without Wire Mode will be used for this run)
)ÚDisplay)ÚvisibleÚsize)”rv   r   Útestr=   r>   r?   r„   Z_browser_shortcutÚsysÚargvÚappendr   Zget_binary_locationÚosÚpathÚexistsZ_cdp_browserr“   ÚjoinÚ	ExceptionrS   rl   ÚcountÚreplaceÚintÚsplitr   ZWINDOW_START_XZWINDOW_START_Yrm   ZCHROME_START_WIDTHZCHROME_START_HEIGHTZHEADLESS_START_WIDTHZHEADLESS_START_HEIGHTr…   Z	is_behaveZ	is_pytestZis_context_managerr    r!   r@   rA   rB   rC   rD   rE   r#   ZSKIP_JS_WAITSr$   ZWAIT_FOR_ANGULARJSr%   r&   r(   r"   r4   r5   r6   r:   Úgetattrr   r   r   Úlowerr   ZChromiumSubsZchromium_subsr;   r<   r1   r2   r3   r)   r*   r+   r-   r.   r/   r0   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   Zrecorder_extrT   rV   rU   rX   rW   rY   rZ   r[   r\   r]   r^   r_   rc   r`   ra   rb   rd   re   rf   Z_swiftshaderrg   rh   ri   rj   rk   rn   ro   rp   Zsave_screenshot_after_testZno_screenshot_after_testrq   rr   rs   rt   Z	dashboardZ_multithreadedZ_reuse_sessionÚstrr	   Zis_linuxÚprintÚ_virtual_displayrƒ   r   Zsbvirtualdisplayr–   Ú_xvfb_displayÚstartZ_is_timeout_changedZSMALL_TIMEOUTZ_SMALL_TIMEOUTZLARGE_TIMEOUTZ_LARGE_TIMEOUTZ_context_of_runnerr,   Údriver)r{   r™   r   Zsys_argvZbrowser_changesZbrowser_setZbrowser_textZbrowser_listZbin_loc_in_optionsÚargZbin_locÚmessagerl   Zwin_xZwin_yrm   ÚwidthÚheightr–   r   r   r€   Ú
beforeTest@  sP   



























þÿÿÿÿþÿÿÿÿÿ









ÿþ
ý








ÿþýüû
ÿ
ÿÿþþ

&


zSeleniumBrowser.beforeTestc                 C   s   t tddƒst ¡  dS )z8This runs after all tests have completed with nosetests.r-   N)r¦   r„   r   r†   )r{   Úresultr   r   r€   Úfinalizeø  s    zSeleniumBrowser.finalizec                 C   sØ   z,t  ¡ r |jjdks | jjjr*| j ¡  W n" ty>   Y n t	yN   Y n0 t
t	ƒ�l t| dd ƒrŽt| jdƒrŽd| _dt_| j ¡  d | _ttdd ƒr¶ttjdƒr¶tj ¡  d t_W d   ƒ n1 sÊ0    Y  d S )NrŠ   r«   ÚstopFrª   )r	   Z
is_windowsr™   r   r­   ZserviceÚprocessÚquitÚAttributeErrorr¡   r   r¦   Úhasattrr«   rƒ   r„   rµ   rª   )r{   r™   r   r   r€   Ú	afterTestý  s6    ÿ
þý

ÿ
þ

ÿ
þ
zSeleniumBrowser.afterTest)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Únamerv   r�   r²   r´   rº   Ú__classcell__r   r   r}   r€   r
      s"   \       Q	   ;r
   )r¾   r�   rš   Ú
contextlibr   Znose.pluginsr   Zseleniumbaser   r„   Zseleniumbase.configr   Zseleniumbase.corer   r   Zseleniumbase.fixturesr   r	   r
   r   r   r   r€   Ú<module>   s   