コード例 #1
0
    def standard_log_in(self):
        """
		Log in bamboo hr by standard log in, that is, not the "log in with Google". 
		Note: Using Google seems more complicated. Besides, if using 2FA hings get very tricky.
		One could use backup codes: read it from file, use it, when using last one log in to google,
		generate new ones, download and substitute the backup codes file with new one... jeez.
		"""

        # Click the link for standard log-in (not google log-in)
        link = S(Link(constants.STANDARD_LOGIN))
        click(link)

        # go to the user_id field and type user
        id_field = S(constants.LOGIN_ID, strategy="css")
        click(id_field)
        type_keys(self.user)
        wait(Css('div.progress').not_exists)  # wait for the domain check

        # go to password field and type the password
        pwd_field = S(constants.PWD_ID, strategy="css")
        click(pwd_field)
        type_keys(self.pwd)

        # click the log in button
        log_in = S(Button(constants.LOGIN_BTN))
        click(log_in)
コード例 #2
0
    def get_box(self):
        from germanium.static import S, js
        code = load_script(__name__, 'box.min.js')

        target_element = S(self._selector).element()

        if not target_element:
            raise Exception("The passed selector (%s) for finding "
                            "the bounding box didn't matched any elements." %
                            self._selector)

        top, right, bottom, left, \
        center, middle, width, height = js(code, target_element)

        self._box = {
            "top": top,
            "right": right,
            "bottom": bottom,
            "left": left,
            "center": center,
            "middle": middle,
            "width": width,
            "height": height
        }

        return self
コード例 #3
0
    def authenticate(self,
                     username,
                     password,
                     wait_disappear=True,
                     *argv,
                     **kw):
        """
        Fills in the username and password into the alert.
        If the germanium parameter is not set it will use instead the
        `germanium.static.get_germanium` instance.
        :param wait_disappear: Wait for the alert to not exist anymore.
        :param password:
        :param username:
        :param argv:
        :param kw:
        :return:
        """
        from germanium.static import S, get_germanium
        alert = S(self).element(*argv, **kw)

        wait(lambda: alert.autenticate(username, password) or True, timeout=1)
        get_germanium()._last_alert = None

        if wait_disappear:
            wait(self.not_exists)
コード例 #4
0
    def _create_selector(self, selector):
        try:
            s = S(eval(selector, self.selector_globals(), locals()))

        except Exception as e:
            raise Exception(f"Unable to create selector {selector}", e)

        return s
コード例 #5
0
 def element(self, *argv, germanium=None, **kw):
     """
     :param argv:
     :param germanium:
     :param kw:
     :return:
     """
     from germanium.static import S
     return S(self, germanium=germanium).element(*argv, **kw)
コード例 #6
0
    def clock_out():
        """
		Click the clock_out button (assume is logged in) and close the browser
		"""

        # TODO: Handle exception if no button is found (eg, already clocked-in)
        clock_out = S(Button(constants.CLOCK_OUT_BTN))
        click(clock_out)
        close_browser()
コード例 #7
0
 def text(self, *argv, **kw):
     """
     Returns the text of the currently visible alert. If the germanium parameter
     is not set it will use instead the `germanium.static.get_germanium` instance.
     :param argv:
     :param kw:
     :return:
     """
     from germanium.static import S
     return S(self).text(*argv, **kw)
コード例 #8
0
 def not_exists(self, *argv, **kw):
     """
     Returns false if an alert is present for the given germanium instance.
     If it is not present, then it will return true. If the germanium parameter
     is not set it will use instead the `germanium.static.get_germanium` instance.
     :param argv:
     :param kw:
     :return:
     """
     from germanium.static import S
     return S(self).not_exists(*argv, **kw)
コード例 #9
0
 def element_list(self, *argv, **kw):
     """
     Returns the existing alert instance as a list for the given
     germanium instance. If the alert is not present, then it will
     return None. If the germanium parameter is not set it will use
     instead the `germanium.static.get_germanium` instance.
     :param argv:
     :param kw:
     :return:
     """
     from germanium.static import S
     return S(self).element(*argv, **kw)
コード例 #10
0
 def exists(self, *argv, germanium=None, **kw):
     """
     If the germanium is provided, the selector is evaluated using
     germanium.S. If the germanium attribute is not provided,
     this is equivalent to: germanium.static.S(self).exists()
     :param argv:
     :param germanium:
     :param kw:
     :return:
     """
     from germanium.static import S
     return S(self, germanium=germanium).exists(*argv, **kw)
コード例 #11
0
 def text(self, *argv, germanium=None, only_visible=True, **kw):
     """
     Returns the text of the `element()` returned by this selector.
     If the germanium is provided, the selector is evaluated using
     germanium.S. If the germanium attribute is not provided,
     this is equivalent to: germanium.static.S(self).text()
     :param argv:
     :param germanium:
     :param kw:
     :return:
     """
     from germanium.static import S
     return S(self, germanium=germanium).text(*argv, **kw)
コード例 #12
0
    def send_keys(self, text, *argv, **kw):
        """
        Types the given keys into the alert.
        If the germanium parameter is not set it will use instead the
        `germanium.static.get_germanium` instance.
        :param text: The text to type into.
        :param argv:
        :param germanium:
        :param kw:
        :return:
        """
        from germanium.static import S, get_germanium
        alert = S(self).element(*argv, **kw)

        alert.send_keys(text)
        get_germanium()._last_alert = None
コード例 #13
0
    def accept(self, wait_disappear=True, *argv, **kw):
        """
        Accepts the current alert from the germanium instance. If the germanium parameter
        is not set it will use instead the `germanium.static.get_germanium` instance.
        :param wait_disappear: Wait for the alert to not exist anymore.
        :param argv:
        :param germanium:
        :param kw:
        :return:
        """
        from germanium.static import S, get_germanium
        alert = S(self).element(*argv, **kw)

        wait(lambda: alert.accept() or True, timeout=1)
        get_germanium()._last_alert = None

        if wait_disappear:
            wait(self.not_exists)