o a @sddlZddlZddlmZddlmZmZddlmZddl m Z ddl m Z Gddde eZed Gd d d eed ZdS) N)contextmanager)LiveServerTestCasetag) classproperty import_string)capfirstcsdeZdZgZdZdZdZdZfddZe ddZ e ddZ e d d Z d d Z d dZZS)SeleniumTestCaseBaseNFc st||||}|jstdd|Ds|S|jrb|jd}||_|js*|jnd}||_|j|_t j |j }|jddD]}||dt ||f|f|||j|j d} t || j| q@|Std |S) z Dynamically create new classes and add them to the test module when multiple browsers specs are provided (e.g. --selenium=firefox,chrome). css&|]\}}|dot|VqdS)testN) startswithcallable).0namevaluer6/usr/lib/python3/dist-packages/django/test/selenium.py s$z/SeleniumTestCaseBase.__new__..rz0.0.0.0Nz%s%s)browserhost external_host __module__zNo browsers specified.)super__new__ranyitemsbrowsers selenium_hubrrsysmodulesrrsetattr__name__unittestskip) clsrbasesattrs test_class first_browserrmodulerbrowser_test_class __class__rrrs0   zSeleniumTestCaseBase.__new__cC td|S)Nz)selenium.webdriver.%s.webdriver.WebDriverrr$rrrrimport_webdriver? z%SeleniumTestCaseBase.import_webdrivercCr-)Nz%selenium.webdriver.%s.options.Optionsrr.rrrimport_optionsCr0z#SeleniumTestCaseBase.import_optionscCsddlm}t||S)Nr)DesiredCapabilities).selenium.webdriver.common.desired_capabilitiesr2getattrupper)r$rr2rrrget_capabilityGs z#SeleniumTestCaseBase.get_capabilitycCs:||j}|jrzd|_W|StyY|Sw|S)NT)r1rheadlessAttributeError)selfoptionsrrrcreate_optionsNs z#SeleniumTestCaseBase.create_optionscCs@|jrddlm}|j|j||jdS||j|dS)Nr) webdriver)command_executordesired_capabilities)r:)rseleniumr<Remoter6rr/r;)r9r<rrrcreate_webdriverWs  z%SeleniumTestCaseBase.create_webdriver)r!r __qualname__rrrrr7r classmethodr/r1r6r;rA __classcell__rrr+rr s (    r r?cs\eZdZdZdZeddZeddZefddZ efd d Z e d d Z Z S) SeleniumTestCase NcCsd|jp|j|jjfS)Nz http://%s:%s)rr server_threadportr$rrrlive_server_urlfsz SeleniumTestCase.live_server_urlcCs |jp|jSN)rrrIrrr allowed_hostjr0zSeleniumTestCase.allowed_hostcs&||_|j|jtdSrK)rAr?implicitly_wait implicit_waitr setUpClassrIr+rrrOns zSeleniumTestCase.setUpClasscs"t|dr |jtdS)Nr?)hasattrr?quitr_tearDownClassInternalrIr+rrrRts  z'SeleniumTestCase._tearDownClassInternalc cs:|jdz dVW|j|jdS|j|jw)z"Disable the default implicit wait.rN)r?rMrN)r9rrrdisable_implicit_wait}s  "z&SeleniumTestCase.disable_implicit_wait)r!rrBrNrrrJrLrCrOrRrrSrDrrr+rrEas  rE) metaclass)rr" contextlibr django.testrrdjango.utils.functionalrdjango.utils.module_loadingrdjango.utils.textrtyper rErrrrs    V