
    Eg{                         d dl Z d dl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  ej        e          Z G d d          ZdS )    N)Path)List)SeleniumManagerException)BaseOptionsc                   r    e Zd ZdZd
dZedefd            Zdede	fdZ
edee	         de	fd	            ZdS )SeleniumManagerzWrapper for getting information from the Selenium Manager binaries.

    This implementation is still in beta, and may change.
    returnNc                     d S )N )selfs    _/var/www/sysmax/venv/lib/python3.11/site-packages/selenium/webdriver/common/selenium_manager.py__init__zSeleniumManager.__init__$   s        c                  D   t           j        } dddd}|                    |           r|                    |           n| }|dk    rdnd}t          t                    j                            ||          }|                                sd}t          | d|           |S )zDetermines the path of the correct Selenium Manager binary.

        :Returns: The Selenium Manager executable location
        macoswindows)darwinwin32cygwinzselenium-manager.exezselenium-managerz-https://github.com/SeleniumHQ/selenium/issuesz& is missing.  Please open an issue on )	sysplatformgetr   __file__parentjoinpathis_filer   )r   dirs	directoryfilepathtrackers         r   
get_binaryzSeleniumManager.get_binary'   s     < 
 
 +/((8*<*<JDHHX&&&(	)2i)?)?%%EWH~~$--i>>||~~ 	eEG*d+c+cZa+c+cdddr   optionsc                    |j         d         }dddddd}||                                vr3t          | dt          |                                                     ||         }t	          |                                           d|d	d
g}|j        r<|                    d           |                    t	          |j                             t          |dd          }|r7|                    d           |                    t	          |                     | 	                    |          }|
                    d          d                                         }t                              d|            |S )z
        Determines the path of the correct driver.
        :Args:
         - browser: which browser to get the driver path for.
        :Returns: The driver path to use
        browserNamechromefirefoxedge	iexplorer)r&   r'   r(   MicrosoftEdgeiez) is not a valid browser.  Choose one of: z	--browserz--outputjsonz--browser-versionbinary_locationNz--browser-path	zUsing driver at: )capabilitieskeysr   liststrr"   browser_versionappendgetattrrunsplitstriploggerdebug)r   r#   browserallowed_browsersargsr-   result
executables           r   driver_locationzSeleniumManager.driver_locationA   s    &}5  #
 
 *//1111*ddTJZJ_J_JaJaEbEbdd   #7+DOO%%&&Wj&Q" 	6KK+,,,KKG344555!'+<dCC 	.KK()))KKO,,---$\\$''+1133
555666r   r>   c                 b   d                     |           }t                              d|            t          j        | t          j        t          j                  }|j                            d                              d          }|j	                            d                              d          }t          j        |          }|d         d         }|j        rt          d| d	| |           |d
         D ].}|d         dk    r t                              |d                    /|S )z
        Executes the Selenium Manager Binary.
        :Args:
         - args: the components of the command being executed.
        :Returns: The log string containing the driver location.
         zExecuting: )stdoutstderrzutf-8
r?   messagezSelenium Manager failed for: z.
logslevelWARN)joinr:   info
subprocessr7   PIPErD   decoderstriprE   r,   loads
returncoder   warning)r>   commandcompleted_procrD   rE   outputr?   items           r   r7   zSeleniumManager.runj   s    ((4..+'++,,,#Z_Z_]]]&--g66==dCC&--g66==dCCF##!),$ 	*+g7+g+gW]+g_e+g+ghhh v 4 4=F**NN4	?333Mr   )r	   N)__name__
__module____qualname____doc__r   staticmethodr   r"   r   r3   rA   r   r7   r   r   r   r   r      s         
        \2'{ 's ' ' ' 'R $s)     \  r   r   )r,   loggingrM   r   pathlibr   typingr   selenium.common.exceptionsr   !selenium.webdriver.common.optionsr   	getLoggerrX   r:   r   r   r   r   <module>rc      s   "       



             ? ? ? ? ? ? 9 9 9 9 9 9		8	$	$b b b b b b b b b br   