예제 #1
0
    def select_nth_member(self, member):
        """Selects member from the list. Members start from (including) 0.

    Args:
        member (int)

    Returns:
        lib.page.widget.info.Widget
    """
        try:
            element = self.members_listed[member]

            # wait for the listed items animation to stop
            selenium_utils.wait_until_stops_moving(element)
            element.click()

            # wait for the info pane animation to stop
            info_pane = selenium_utils.get_when_clickable(
                self._driver, locator.ObjectWidget.INFO_PANE)
            selenium_utils.wait_until_stops_moving(info_pane)

            return self._info_pane_cls(self._driver)
        except exceptions.StaleElementReferenceException:
            self.members_listed = self._driver.find_elements(
                *locator.ObjectWidget.MEMBERS_TITLE_LIST)
            return self.select_nth_member(member)
        except exceptions.TimeoutException:
            # sometimes the click to the listed member results in hover
            return self.select_nth_member(member)
예제 #2
0
 def expand(self):
     """Expand Tree View item if it is not expanded already."""
     from lib.page.widget.widget_base import CustomAttributesItemContent
     if not self.is_expanded:
         self.expand_btn.click()
         selenium_utils.wait_until_stops_moving(self.expand_btn)
     return CustomAttributesItemContent(self._driver, self.text)
예제 #3
0
파일: base.py 프로젝트: zidarsk8/ggrc-core
 def expand(self):
   """Expand Tree View item if it is not expanded already."""
   from lib.page.widget.widget_base import CustomAttributesItemContent
   if not self.is_expanded:
     self.item_btn.click()
     selenium_utils.wait_until_stops_moving(self.item_btn)
   return CustomAttributesItemContent(self._driver, self.text)
예제 #4
0
 def select_member_by_num(self, num):
   """Select member from list of members by number (start from 0).
   Args: num (int)
   Return: lib.page.widget.info.Widget
   """
   # pylint: disable=not-callable
   selenium_utils.wait_for_js_to_load(self._driver)
   self._set_members_listed()
   try:
     member = self.members_listed[num]
     # wait for the listed items animation to stop
     selenium_utils.wait_until_stops_moving(member)
     selenium_utils.click_via_js(self._driver, member)
     # wait for the info pane animation to stop
     info_panel = selenium_utils.get_when_clickable(
         self._driver, locator.ObjectWidget.INFO_PANE)
     selenium_utils.wait_until_stops_moving(info_panel)
     return self.info_widget_cls(self._driver)
   except exceptions.StaleElementReferenceException:
     self.members_listed = self._driver.find_elements(
         *locator.ObjectWidget.MEMBERS_TITLE_LIST)
     return self.select_member_by_num(num)
   except exceptions.TimeoutException:
     # sometimes the click to the listed member results in hover
     return self.select_member_by_num(num)
예제 #5
0
 def select_member_by_num(self, num):
     """Select member from list of members by number (start from 0).
 Args: num (int)
 Return: lib.page.widget.info.Widget
 """
     # pylint: disable=not-callable
     selenium_utils.wait_for_js_to_load(self._driver)
     self._set_members_listed()
     # need "try-except" block due to issue GGRC-1675
     try:
         member = self.members_listed[num]
         # wait for the listed items animation to stop
         selenium_utils.wait_until_stops_moving(member)
         selenium_utils.click_via_js(self._driver, member)
         # wait for the info pane animation to stop
         info_panel = selenium_utils.get_when_clickable(
             self._driver, locator.ObjectWidget.INFO_PANE)
         selenium_utils.wait_until_stops_moving(info_panel)
     except exceptions.StaleElementReferenceException:
         self.members_listed = self._driver.find_elements(
             *locator.ObjectWidget.MEMBERS_TITLE_LIST)
         return self.select_member_by_num(num)
     except exceptions.TimeoutException:
         # sometimes the click to the listed member results in hover
         return self.select_member_by_num(num)
     return self.info_widget_cls(self._driver)
예제 #6
0
 def select_member_by_title(self, title):
     """Select member in Tree View by member's title."""
     item = [
         _item for _item in self.tree_view_items_elements()
         if title in _item.text.splitlines()
     ][0]
     selenium_utils.wait_until_stops_moving(item)
     item.click()
 def select_el_in_tree_view(self, el_title):
     """Select the element in tree view by element's title."""
     item = [
         _item for _item in self.tree_view_items_elements()
         if el_title in _item.text.splitlines()
     ][0]
     selenium_utils.wait_until_stops_moving(item)
     item.click()
예제 #8
0
 def test_lhn_stays_expanded(self, header_dashboard, selenium):
   """Tests if, after opening LHN, it slides out and stays expanded."""
   lhn_menu = header_dashboard.open_lhn_menu()
   initial_position = lhn_menu.my_objects.element.location
   selenium_utils.wait_until_stops_moving(lhn_menu.my_objects.element)
   selenium_utils.hover_over_element(
       selenium, dashboard.Header(selenium).button_my_tasks.element)
   assert initial_position == lhn.Menu(selenium).my_objects.element.location
예제 #9
0
 def open_add_new_ca_modal(self):
   """Open Add Attribute modal and return Custom Attribute Modal."""
   selenium_utils.wait_until_stops_moving(self.button_add.element)
   selenium_utils.scroll_into_view(self._driver, self.button_add.element)
   selenium_utils.get_when_clickable(self._driver, self._locators.ADD_BTN)
   selenium_utils.get_when_invisible(
       self._driver, self._locators.TREE_SPINNER)
   self.button_add.click()
   return CustomAttributeModal(self._driver)
예제 #10
0
 def open_add_new_ca_modal(self):
   """Open Add Attribute modal and return Custom Attribute Modal."""
   selenium_utils.wait_until_stops_moving(self.add_btn.element)
   selenium_utils.scroll_into_view(self._driver, self.item_el)
   selenium_utils.get_when_clickable(self._driver, self._locators.ADD_BTN_CSS)
   selenium_utils.wait_until_not_present(
       self._driver, self._locators.TREE_SPINNER_CSS)
   self.add_btn.click()
   return CustomAttributeModal(self._driver)
예제 #11
0
파일: lhn.py 프로젝트: wangsaisai/ggrc-core
 def _set_visible_members(self):
   try:
     for element in self.members_loaded:
       selenium_utils.wait_until_stops_moving(element)
     self.members_visible = [
         element for element in self.members_loaded if element.is_displayed()]
   except selenium_exception.StaleElementReferenceException:
     self._update_loaded_members()
     self._set_visible_members()
예제 #12
0
 def open_add_new_ca_modal(self):
     """Open Add Attribute modal and return CustomAttributeModal PageObject."""
     selenium_utils.wait_until_stops_moving(self.button_add.element)
     selenium_utils.scroll_into_view(self._driver, self.button_add.element)
     selenium_utils.get_when_clickable(self._driver, self._locator.ADD_BTN)
     selenium_utils.get_when_invisible(self._driver,
                                       self._locator.TREE_SPINNER)
     self.button_add.click()
     return CustomAttributeModal(self._driver)
예제 #13
0
파일: lhn.py 프로젝트: egorhm/ggrc-core
 def _set_visible_members(self):
   try:
     for element in self.members_loaded:
       selenium_utils.wait_until_stops_moving(element)
     self.members_visible = [
         element for element in self.members_loaded if element.is_displayed()]
   except selenium_exception.StaleElementReferenceException:
     self._update_loaded_members()
     self._set_visible_members()
예제 #14
0
 def open_add_new_ca_modal(self):
   """Open Add Attribute modal and return Custom Attribute Modal."""
   selenium_utils.wait_until_stops_moving(self.add_btn.element)
   selenium_utils.scroll_into_view(self._driver, self.item_el)
   selenium_utils.get_when_clickable(self._driver, self._locators.ADD_BTN_CSS)
   selenium_utils.wait_until_not_present(
       self._driver, self._locators.TREE_SPINNER_CSS)
   self.add_btn.click()
   return CustomAttributeModal(self._driver)
예제 #15
0
 def add_new_custom_attribute(self):
   """
   Returns:
       new_custom_attribute.ModalCustomAttributes
   """
   selenium_utils.wait_until_stops_moving(self.button_add.element)
   selenium_utils.scroll_into_view(self._driver, self.button_add.element)
   self.button_add.click()
   return self._cls_new_attrb_modal(self._driver)
예제 #16
0
 def select_member_by_title(self, title):
     """Select member on Tree View by title.
 Return: lib.page.widget.info_widget."obj_name"
 """
     item = [
         _item for _item in self.tree_view_items_elements()
         if title in _item.text.splitlines()
     ][0]
     selenium_utils.wait_until_stops_moving(item)
     item.click()
     return self.info_widget_cls(self._driver)
예제 #17
0
    def test_lhn_stays_expanded(self, selenium):
        """Tests if, after opening the LHN, it slides out and stays expanded."""
        conftest_utils.navigate_to_page_with_lhn(selenium)

        lhn_menu = dashboard.Header(selenium).open_lhn_menu()
        initial_position = lhn_menu.my_objects.element.location

        selenium_utils.wait_until_stops_moving(lhn_menu.my_objects.element)
        selenium_utils.hover_over_element(
            selenium,
            dashboard.Header(selenium).button_my_tasks.element)

        assert initial_position == \
            lhn.Menu(selenium).my_objects.element.location
예제 #18
0
    def get_header_and_value_txt_from_people_scopes(self, header_text):
        """Get with controlling header and value text from people's scopes elements
    according to header text.

    Example:
    'header_text' = 'ASSIGNEE(S)', return: ['ASSIGNEE(S)', '*****@*****.**']
    """
        # pylint: disable=invalid-name
        # pylint: disable=expression-not-assigned
        _header_msg, _value_msg = ("people header: {}, count: {}",
                                   "people list: {}, count: {}")
        people_scopes = self.core_elem.find_elements(
            *self._locators.PEOPLE_HEADERS_AND_VALUES_CSS)
        [
            selenium_utils.wait_until_stops_moving(people_scope)
            for people_scope in people_scopes
        ]
        matched_people_scopes = [
            people_scope for people_scope in people_scopes
            if header_text in people_scope.text
        ]
        if len(matched_people_scopes) != 1:
            raise ValueError(
                messages.ExceptionsMessages.err_results_are_different.format(
                    _header_msg.format(header_text, "1"),
                    _value_msg.format([
                        matched_people_scope.text
                        for matched_people_scope in matched_people_scopes
                    ], len(matched_people_scopes))))
        people_scope = matched_people_scopes[0]
        _people_header = people_scope.find_element(
            *self._locators.PEOPLE_HEADER_CSS).text
        _people_value = people_scope.find_element(
            *self._locators.PEOPLE_VALUE_CSS).text
        # 'ASSIGNEE(S)\n(2)' to str 'ASSIGNEE(S)' and int '2'
        _people_header_parts = _people_header.splitlines()
        people_header_txt = _people_header_parts[0]
        people_count_from_header = (int(
            re.search(regex.TEXT_WO_PARENTHESES,
                      _people_header_parts[1]).group(1)))
        # filter: "\[email protected]\n(Inactive user)" to '*****@*****.**'
        people_value_txt = [
            person for person in _people_value.splitlines()
            if person != roles.NO_ROLE_UI
        ]
        # if counters are same or None
        if not (
            (people_count_from_header == len(people_value_txt)) or
            (people_count_from_header == 0 and people_value_txt == ["None"])):
            raise ValueError(
                messages.ExceptionsMessages.err_counters_are_different.format(
                    _header_msg.format(_people_header_parts,
                                       str(people_count_from_header)),
                    _value_msg.format(people_value_txt,
                                      len(people_value_txt))))
        return (people_header_txt,
                None if people_value_txt == ["None"] else people_value_txt)
예제 #19
0
  def get_header_and_value_txt_from_people_scopes(self, header_text):
    """Get with controlling header and value text from people's scopes elements
    according to header text.

    Example:
    'header_text' = 'ASSIGNEE(S)', return: ['ASSIGNEE(S)', '*****@*****.**']
    """
    # pylint: disable=invalid-name
    # pylint: disable=expression-not-assigned
    _header_msg, _value_msg = (
        "people header: {}, count: {}", "people list: {}, count: {}")
    people_scopes = self.core_elem.find_elements(
        *self._locators.PEOPLE_HEADERS_AND_VALUES_CSS)
    [selenium_utils.wait_until_stops_moving(people_scope)
     for people_scope in people_scopes]
    matched_people_scopes = [people_scope for people_scope in people_scopes
                             if header_text in people_scope.text]
    if len(matched_people_scopes) != 1:
      raise ValueError(
          messages.ExceptionsMessages.err_results_are_different.format(
              _header_msg.format(header_text, "1"),
              _value_msg.format(
                  [matched_people_scope.text
                   for matched_people_scope in matched_people_scopes],
                  len(matched_people_scopes))))
    people_scope = matched_people_scopes[0]
    _people_header = people_scope.find_element(
        *self._locators.PEOPLE_HEADER_CSS).text
    _people_value = people_scope.find_element(
        *self._locators.PEOPLE_VALUE_CSS).text
    # 'ASSIGNEE(S)\n(2)' to str 'ASSIGNEE(S)' and int '2'
    _people_header_parts = _people_header.splitlines()
    people_header_txt = _people_header_parts[0]
    people_count_from_header = (
        int(re.search(regex.TEXT_WO_PARENTHESES,
                      _people_header_parts[1]).group(1)))
    # filter: "\[email protected]\n(Inactive user)" to '*****@*****.**'
    people_value_txt = [person for person in _people_value.splitlines()
                        if person != roles.NO_ROLE_UI]
    # if counters are same or None
    if not ((people_count_from_header == len(people_value_txt)) or
       (people_count_from_header == 0 and people_value_txt == ["None"])):
      raise ValueError(
          messages.ExceptionsMessages.err_counters_are_different.format(
              _header_msg.format(
                  _people_header_parts, str(people_count_from_header)),
              _value_msg.format(people_value_txt, len(people_value_txt))))
    return (people_header_txt,
            None if people_value_txt == ["None"] else people_value_txt)
예제 #20
0
파일: base.py 프로젝트: javz1/ggrc-core
 def expand(self):
     """Expand Tree View item if it is not expanded already."""
     if not self.is_expanded:
         self.item_btn.click()
         selenium_utils.wait_until_stops_moving(self.item_btn)
예제 #21
0
 def collapse(self):
     """Collapse Tree View item if it is expanded."""
     if self.is_expanded:
         self.expand_btn.click()
         selenium_utils.wait_until_stops_moving(self.expand_btn)
예제 #22
0
파일: base.py 프로젝트: zidarsk8/ggrc-core
 def collapse(self):
   """Collapse Tree View item if it is expanded."""
   if self.is_expanded:
     self.item_btn.click()
     selenium_utils.wait_until_stops_moving(self.item_btn)