コード例 #1
0
    def authenticate_webdriver(
        self,
        driver: WebDriver,
        user: "******",
    ) -> WebDriver:
        """
        Default AuthDriverFuncType type that sets a session cookie flask-login style
        :return: The WebDriver passed in (fluent)
        """
        # Short-circuit this method if we have an override configured
        if self._auth_webdriver_func_override:
            return self._auth_webdriver_func_override(driver, user)

        # Setting cookies requires doing a request first
        driver.get(headless_url("/login/"))

        if user:
            cookies = self.get_auth_cookies(user)
        elif request.cookies:
            cookies = request.cookies
        else:
            cookies = {}

        for cookie_name, cookie_val in cookies.items():
            driver.add_cookie(dict(name=cookie_name, value=cookie_val))

        return driver
コード例 #2
0
 def auth(self, user: "******") -> WebDriver:
     # Setting cookies requires doing a request first
     driver = self.create()
     driver.get(headless_url("/login/"))
     return self._auth_func(driver, user)