Пример #1
0
 def wait_for_element_to_be_enabled(self,
                                    element,
                                    el_description='',
                                    timeout=TIMEOUT,
                                    poll_frequency=POLL_FREQUENCY,
                                    raise_exception=True):
     """An expectation for checking that the WebElement is enabled and available for interaction.
         :param element : watch in description to this module
         :param el_description (str) description of the element
         :param timeout: (int): time to wait for condition
         :param poll_frequency: (float) sleep interval between calls
         param: raise_exception (bool): whether to raise an exception when expected condition
         not met or not.
     Returns:
         WebElement once it is clickable
         bool: False if WebElement is not clickable and raise_exception is False
     """
     web_element, el_description = Element(
         self.session).initialize_webelement(element, el_description)
     self.logger.info("Waiting for following element to be enabled : '%s'",
                      el_description)
     try:
         return WebDriverWait(
             self.driver, timeout,
             poll_frequency).until(lambda: web_element.is_enabled())
     except TimeoutException:
         if raise_exception:
             raise ElementIsDisabledException(
                 "Element '%s' is disabled. Waited for '%s' seconds.".
                 format(el_description, timeout))
         return False
Пример #2
0
    def set_value_for_tokenpanel_dropdown_v3(self, dropdown, list):
        """
        Click on the arrow button and open dropdown. Then choose folder/value from the list.
        :param dropdown:(str) the tuple of arrow button on dropdown
        :param list:(array []) the list of dropdown menu(path).
        Example: folder-folder-value ['Network Access', 'Authentication Status', 'AuthenticationPassed']
        """
        dropdown_list = (
            'CSS_SELECTOR',
            '.dijitPopup .xwtobjectselectorlist [dojoattachpoint="osItemNode"]'
        )
        token_loader = (
            'CSS_SELECTOR',
            '[class="xwtOSWaitIndicator"] img[style*="display: block;"]')
        token_panel = ('CSS_SELECTOR',
                       '.dijitPopup .dijitVisible[role="tabpanel"]')
        self.click_to(dropdown)
        for one in list:
            for dropdown_elem in Element(self.driver,
                                         dropdown_list)(multiple=True,
                                                        implicitly_timeout=2):
                if one.lower() in dropdown_elem.text.lower():

                    if not one == list[-1]:
                        self.action.click(
                            dropdown_elem.find_element_by_css_selector(
                                '[id="osItemNavNode"]'))
                        self.action.handle_loader(token_loader, time_appear=4)
                    else:
                        self.action.click(dropdown_elem)
                        self.waits.wait_for_web_element_not_visible(
                            token_panel, timeout=3, raise_exception=False)
                        return
                    break
        raise FlowFailedException("Element is absent. Check test data")
Пример #3
0
 def click_specifed_radio_button(self, radio_button_locator):
     """click radio button by specified locator"""
     self.action.click(radio_button_locator)
     # if not Element(self.session.driver, radio_button_locator)().is_selected():
     if not self.action.is_checked(
             Element(self.session.driver, radio_button_locator)()):
         raise FlowFailedException(
             "Radio button by locator  '{}' was not"
             " selected after clicking on it".format(radio_button_locator))
Пример #4
0
 def wait_for_web_element_attribute_not_to_contain(self,
                                                   element,
                                                   text,
                                                   el_description='',
                                                   attribute='value',
                                                   timeout=TIMEOUT,
                                                   raise_exception=True):
     """ An expectation for checking if the given string is not present in webelement's attribute
     Args:
         :param element : watch in description to this module
         :param el_description (str) description of the element
         :param text - (str) specified text, excepted to be present in elements attribute
         :param timeout: (int): time to wait for condition
         param: raise_exception (bool): whether to raise an exception when expected condition
         not met or not.
         :param attribute: (str): attribute of element
         :param timeout: (int): time to wait
     Returns:
         bool: True if the text present in the element's attribute
         bool: False if not present in the element's attribute and raise_exception is False
     Raises:
         FlowFailedException: When condition is not met and raise_exception is True
     """
     web_element, el_description = Element(
         self.session).initialize_webelement(element, el_description)
     poll_frequency = 0.5
     self.logger.info(
         "Waiting for '{0}' to be no longer present in attribute '{1}' of element '{2}'"
         .format(text, attribute, el_description))
     try:
         return WebDriverWait(self.driver, timeout, poll_frequency).until(
             lambda: text not in web_element.get_attribute(attribute))
     except TimeoutException:
         if raise_exception:
             raise FlowFailedException(
                 "Text '{0}' is still present in attribute of  '{1}' of WebElement '{2}'."
                 "Waited for '{3}' seconds.".format(text, attribute,
                                                    el_description,
                                                    timeout))
Пример #5
0
 def check_validation_error(self, raise_exception=True):
     """Check if validation error present"""
     validation_error_locator = ("CSS_SELECTOR", ".has-error")
     validation_error = Element(self.session.driver,
                                validation_error_locator)
     if self.action.check_is_element_present_in_dom(
             validation_error_locator, timeout=2):
         if raise_exception:
             raise FlowFailedException(
                 'Following validation error is present on page : "{}"'.
                 format(validation_error().text))
         else:
             LOGGER.info(
                 'Validation error found on page : "{}". Check correctness of filled data.'
                 .format(validation_error().text))
             return True
     return False
Пример #6
0
    def wait_for_web_element_visible(self,
                                     element,
                                     el_description='',
                                     timeout=TIMEOUT,
                                     poll_frequency=POLL_FREQUENCY,
                                     raise_exception=True):
        """ An expectation for checking that the element is present in the DOM and
            is visible.
            :param element : watch in description to this module
            :param el_description (str) description of the element
            :param timeout: (int): time to wait for condition
            poll_frequency (float): sleep interval between calls
            raise_exception (bool): whether to raise an exception when expected condition not met
            or not.
        Returns: True - if element is present and visible. Returns false - if element is invisible
        and raise_exception is False.
        """
        try:
            web_element, el_description = Element(
                self.session).initialize_webelement(element,
                                                    el_description,
                                                    timeout=timeout)
            self.logger.info(
                "Waiting for following element to be displayed : '%s'" %
                el_description)
            return WebDriverWait(self.driver, timeout, poll_frequency).until(
                ec.visibility_of(web_element))
        except (ElementNotFoundExcepiton,
                NoSuchElementException) as element_not_found_e:
            if raise_exception:
                raise element_not_found_e
            else:
                self.logger.info(
                    "WebElement '%s' is not present in DOM. Waited for '%s' seconds."
                    % (el_description, timeout))

        except TimeoutException:
            if raise_exception:
                raise ElementNotVisibleExcepiton(
                    "WebElement '%s' is not visible in DOM. Waited for '%s' seconds."
                    % (el_description, timeout))

        return False
Пример #7
0
    def wait_for_number_of_elements_present(self,
                                            element,
                                            el_description='',
                                            expected_number=1,
                                            precisely=False,
                                            timeout=TIMEOUT,
                                            raise_exception=True):
        """ An expectation for checking quantity of elements in DOM >= expected quantity.
        Args:
            :param element : watch in description to this module
            :param el_description (str) description of the element
            :param expected_number: (int): quantity of elements expected to be present in DOM
            timeout (int): time to wait
            poll_frequency (float): sleep interval between calls
            raise_exception (bool): whether or not to raise an exception or return False
        Returns:
            bool: True if condition met
            bool: False if condition not met and raise_exception is False
        """
        web_elements, el_description = Element(
            self.session).initialize_webelement(element,
                                                el_description,
                                                multiple=True)
        self.logger.info(
            "Waiting for number of present elements by locator '{}'  >= expected number : '{}'"
            .format(el_description, expected_number))

        try:
            return WebDriverWait(self.driver, timeout).until(
                lambda length: len(web_elements) >= expected_number)

        except TimeoutException:
            if raise_exception:
                raise FlowFailedException(
                    "Number of webelements by locator '{}' present in DOM is : '{}'. "
                    "Expected number of elements to be present is '{}'. Waited for '{}' seconds."
                    .format(el_description, len(web_elements), expected_number,
                            timeout))
            else:
                return False
Пример #8
0
    def wait_for_web_element_not_visible(self,
                                         element,
                                         el_description='',
                                         timeout=TIMEOUT,
                                         poll_frequency=POLL_FREQUENCY,
                                         raise_exception=False):
        """ An expectation for checking that the WebElement is not present in the DOM or is invisible.
        (not displayed/ hidden)
        :param element : watch in description to this module
        :param el_description (str) description of the elementWebElement type
                - specify description of passed element.
        :param timeout: (int): time to wait for condition
        poll_frequency (float): sleep interval between calls
        raise_exception (bool): whether to raise an exception when expected condition not met
        or not.
        Returns:
            obj: WebElement once it is located and then become invisible
            bool: False if the WebElement not became invisible, or disappear from DOM, after specified time out.
        """
        try:
            self.logger.info(
                "Waiting for webelement {} to be no longer visible or present".
                format(el_description))
            web_element, el_description = Element(
                self.session).initialize_webelement(element,
                                                    el_description,
                                                    timeout=1)
            return WebDriverWait(self.driver, timeout, poll_frequency).until(
                ec.invisibility_of_element_located(web_element))
        except TimeoutException:
            if raise_exception:
                raise FlowFailedException(
                    "WebElement '%s' is still visible. Waited element not to be visible for '%s' seconds."
                    % (el_description, timeout))
            return False

        except ElementNotFoundExcepiton:
            return True
Пример #9
0
 def wait_for_text_not_to_be_present_in_element(self,
                                                element,
                                                text,
                                                el_description='',
                                                timeout=TIMEOUT,
                                                raise_exception=True):
     """ An expectation for checking if the given text is
     present in the specified element.
     Similar to checking if text not in ".text" method called on a webelement
     Args:
         :param element : watch in description to this module
         :param el_description (str) description of the element
         :param text - (str) specified text, excepted to be not longer present in element
         :param timeout: (int): time to wait for condition
         param: raise_exception (bool): whether to raise an exception when expected condition
         not met or not.
     Returns:
         bool: True if the text not present in the element's inner text
         bool: False if still present and raise_exception is False
     Raises:
         FlowFailedException: When condition is not met and raise_exception is True
     """
     web_element, el_description = Element(
         self.session).initialize_webelement(element, el_description)
     self.logger.info(
         "Waiting for text: {0} to be no longer present in element: {1}".
         format(text, el_description))
     try:
         return WebDriverWait(
             self.driver,
             timeout).until(lambda: text not in web_element.text)
     except TimeoutException:
         if raise_exception:
             raise FlowFailedException(
                 "Text '{0}' is still present in Element '{1}'. Waited for '{2}' seconds."
                 .format(text, el_description, timeout))
         else:
             return False
 def nickname_input(self):
     return Element(self.session, ("CSS_SELECTOR", "input#nickname"))
Пример #11
0
 def submit_login_button(self):
     return Element(self.session, ("CSS_SELECTOR", 'button[type="submit"]'))
Пример #12
0
 def events_search_form(self):
     return Element(self.session,
                    ("CSS_SELECTOR", ".js-ds-layout-events-search-form"))
Пример #13
0
 def booking_home_logo(self):
     return Element(self.session,
                    ("CSS_SELECTOR", "#top #logo_no_globe_new_logo"))
 def personal_room_button(self): return Element(self.session, ("CSS_SELECTOR", ".profile-menu__item"))
 @property
 def open_user_account_button(self): return Element(self.session, ("CSS_SELECTOR", "#profile-menu-trigger--content"))
 @property
Пример #16
0
 def password_input(self):
     return Element(self.session, ("CSS_SELECTOR", 'input#password'))
 def country_drop_down(self):
     return Element(self.session, ("CSS_SELECTOR", "select#nationality"))
Пример #18
0
 def calendar_body(self):
     return Element(self.session,
                    ("CSS_SELECTOR", ".bui-calendar[style*='block']"))
Пример #19
0
 def calendar_previous(self):
     return Element(self.session,
                    ("CSS_SELECTOR", '.bui-calendar__control--prev"]'))
 def profile_content_container(self): return Element(self.session, ("CSS_SELECTOR", ".profile-area__content-container"))
 @property
 def navigate_to_settings_page(self):
     return Element(
         self.session,
         ("XPATH",
          "//*[@id='profile-menu']//*[contains(text(), 'Settings')]"))
 def navigate_to_account_menu(self):
     return Element(self.session, ("CSS_SELECTOR", "#current_account"))
 def checkin_expander(self): return Element(self.session, ("CSS_SELECTOR", '[data-mode="checkin"]'))
 @property
 def email_confirm_input(self): return Element(self.session, ("CSS_SELECTOR", ".email-confirm-banner__email-text"))
 @property
 def bday_drop_down(self):
     return Element(self.session, ("CSS_SELECTOR", "select#bday"))
 def bmonth_drop_down(self):
     return Element(self.session, ("CSS_SELECTOR", "select#bmonth"))
Пример #27
0
 def calendar_next(self):
     return Element(self.session,
                    ("CSS_SELECTOR", ".bui-calendar__control--next"))
 def byear_drop_down(self):
     return Element(self.session, ("CSS_SELECTOR", "select#byear"))
Пример #29
0
 def calendar_active_date(self):
     return Element(self.session,
                    ("CSS_SELECTOR", 'td.bui-calendar__date[data-date]'))
Пример #30
0
 def next_button(self):
     return Element(self.session,
                    ("CSS_SELECTOR", '.transition button[type="submit"]'))