Beispiel #1
0
 def collect_lcas_attr_name_value(self, ca_header_text, list_text_cas_scopes,
                                  scope):
   """Collect all local attribute with values"""
   ca_type = scope.get_attribute("class")
   if "custom-attribute-checkbox" in ca_type:
     ca_value = unicode(int(base.Checkbox(self._driver, scope.find_element(
         *self._locators.CAS_CHECKBOXES)).is_checked_via_js()))
   elif "custom-attribute-date" in ca_type:
     ca_value = scope.find_element(
         *locator.WidgetInfoPanel.
         DATE_CA_INPUT).get_attribute("value")
   elif "custom-attribute-text" in ca_type:
     ca_value = scope.find_element(
         *locator.WidgetInfoPanel.RICH_TEXT_CA_INPUT).text
   elif "custom-attribute-input" in ca_type:
     ca_value = scope.find_element(
         *locator.WidgetInfoPanel.TEXT_CA_INPUT).text
   elif "custom-attribute-dropdown" in ca_type:
     ca_value = (
         selenium_utils.get_element_value_js(
             self._driver, scope.find_element(
                 *locator.WidgetInfoPanel.DROPDOWN_CA_ITEM)))
   elif "custom-attribute-person" in ca_type:
     ca_value = scope.find_element(
         *locator.WidgetInfoPanel.PERSON_CA).text
   else:
     raise NotImplementedError()
   list_text_cas_scopes.append([ca_header_text, ca_value])
Beispiel #2
0
 def get_headers_and_values_dict_from_cas_scopes(self, is_gcas_not_lcas=True):  # noqa: ignore=C901
   """Get text of all CAs headers and values elements scopes and convert it to
   dictionary. If 'is_gcas_not_lcas' then get GCAs, if not 'is_gcas_not_lcas'
   then get LCAs.
   Example:
   :return {'ca_header1': 'ca_value1', 'ca_header2': 'ca_value2', ...}
   """
   # pylint: disable=invalid-name
   # pylint: disable=too-many-branches
   selenium_utils.wait_for_js_to_load(self._driver)
   cas_locator = (self._locators.CAS_HEADERS_AND_VALUES if is_gcas_not_lcas
                  else self._locators.LCAS_HEADERS_AND_VALUES)
   cas_headers_and_values = self.info_widget_elem.find_elements(*cas_locator)
   dict_cas_scopes = {}
   if len(cas_headers_and_values) >= 1:
     list_text_cas_scopes = []
     for scope in cas_headers_and_values:
       ca_header_text = scope.text.splitlines()[0]
       if len(scope.text.splitlines()) >= 2:
         if scope.text.splitlines()[1].strip():
           list_text_cas_scopes.append(
               [ca_header_text, scope.text.splitlines()[1]])
         else:
           list_text_cas_scopes.append([ca_header_text, None])
       if len(scope.text.splitlines()) == 1:
         if (element.AdminWidgetCustomAttributes.CHECKBOX.upper() in
                 ca_header_text):
           list_text_cas_scopes.append(
               [ca_header_text,
                unicode(int(base.Checkbox(self._driver, scope.find_element(
                    *self._locators.CAS_CHECKBOXES)).is_checked_via_js()))
                ])
         else:
           list_text_cas_scopes.append([ca_header_text, None])
       if not is_gcas_not_lcas:
         self.collect_lcas_attr_name_value(
             ca_header_text, list_text_cas_scopes, scope)
     cas_headers, _cas_values = [list(text_cas_scope) for text_cas_scope
                                 in zip(*list_text_cas_scopes)]
     # conversion
     cas_values = []
     for ca_val in _cas_values:
       if ca_val is None:
         cas_values.append(None)
       elif ca_val == users.SUPERUSER_EMAIL:
         # Example User
         cas_values.append(
             unicode(objects.get_singular(objects.PEOPLE).title()))
       elif "/" in ca_val and len(ca_val) == 10:
         # Date
         _date = ca_val.split("/")
         cas_values.append(unicode("{y}-{m}-{d}".format(
             y=_date[2], m=_date[0], d=_date[1])))
       else:
         # Other
         cas_values.append(ca_val)
     dict_cas_scopes = dict(zip(cas_headers, cas_values))
   return dict_cas_scopes
Beispiel #3
0
 def __init__(self, driver):
   super(UserList, self).__init__(driver)
   self.button_logout = base.Button(
       self._driver, self.locators.BUTTON_LOGOUT)
   self.notifications = base.Label(
       self._driver, self.locators.NOTIFICATIONS)
   self.checkbox_daily_digest = base.Checkbox(
       self._driver, self.locators.CHECKBOX_DAILY_DIGEST)
   self.button_help = base.Button(
       self._driver, self.locators.BUTTON_HELP)
Beispiel #4
0
 def __init__(self, driver):
     super(UserList, self).__init__(driver)
     self.button_logout = base.Button(self._driver,
                                      self.locators.BUTTON_LOGOUT)
     self.notifications = base.Label(self._driver,
                                     self.locators.NOTIFICATIONS)
     self.checkbox_daily_digest = base.Checkbox(
         self._driver, self.locators.CHECKBOX_DAILY_DIGEST)
     self.button_admin_dashboard = base.Button(
         self._driver, self.locators.BUTTON_ADMIN_DASHBOARD)
     self.button_help = base.Button(self._driver, self.locators.BUTTON_HELP)
     self.button_data_export = base.Button(self._driver,
                                           self.locators.BUTTON_DATA_EXPORT)
Beispiel #5
0
 def __init__(self, driver):
   super(CustomAttributeModal, self).__init__(driver)
   self.attribute_title = base.Label(
       self._driver, self._locator.ATTRIBUTE_TITLE)
   self.inline_help = base.Label(self._driver, self._locator.INLINE_HELP)
   self.attribute_type = base.Label(
       self._driver, self._locator.ATTRIBUTE_TYPE)
   self.placeholder = base.Label(self._driver, self._locator.PLACEHOLDER)
   self.mandatory = base.Label(self._driver, self._locator.MANDATORY)
   self.ui_inline_help = base.TextInputField(
       self._driver, self._locator.UI_INLINE_HELP)
   self.ui_placeholder = base.TextInputField(
       self._driver, self._locator.UI_PLACEHOLDER)
   self.checkbox_mandatory = base.Checkbox(
       self._driver, self._locator.CHECKBOX_MANDATORY)
Beispiel #6
0
 def __init__(self, driver):
   super(CustomAttributeModal, self).__init__(driver)
   self.attribute_title = base.Label(
       self._driver, self._locators.ATTRIBUTE_TITLE)
   self.inline_help = base.Label(self._driver, self._locators.INLINE_HELP)
   self.attribute_type = base.Label(
       self._driver, self._locators.ATTRIBUTE_TYPE)
   self.placeholder = base.Label(self._driver, self._locators.PLACEHOLDER)
   self.mandatory = base.Label(self._driver, self._locators.MANDATORY)
   self.ui_inline_help = None
   self.ui_placeholder = None
   self.checkbox_mandatory = base.Checkbox(
       self._driver, self._locators.CHECKBOX_MANDATORY)
   self.attribute_type_selector = base.DropdownStatic(
       self._driver, self._locators.ATTRIBUTE_TYPE_SELECTOR)
   self.ui_possible_values = None
Beispiel #7
0
 def __init__(self, driver):
     super(CustomAttributeModal, self).__init__(driver)
     self.attr_title_lbl = base.Label(self.modal_window,
                                      self._locators.ATTR_TITLE_LBL_CSS)
     self.attr_type_lbl = base.Label(self.modal_window,
                                     self._locators.ATTR_TYPE_CSS)
     self.attr_type_selector_dd = base.DropdownStatic(
         self.modal_window, self._locators.ATTR_TYPE_SELECTOR_DD_CSS)
     self.mandatory_lbl = base.Label(self.modal_window,
                                     self._locators.MANDATORY_LBL_CSS)
     self.mandatory_cb = base.Checkbox(self.modal_window,
                                       self._locators.MANDATORY_CB_CSS)
     self.inline_help_lbl = base.Label(self.modal_window,
                                       self._locators.INLINE_HELP_LBL_CSS)
     self.inline_help_ui = None
     self.placeholder_lbl = base.Label(self.modal_window,
                                       self._locators.PLACEHOLDER_LBL_CSS)
     self.placeholder_ui = None
     self.possible_values_ui = None
Beispiel #8
0
 def get_headers_and_values_text_from_cas_scopes(self):  # flake8: noqa
     """Get and convert to entities form all headers and values elements text
 from CAs scopes elements.
 Example:
 :return [['ca_header1', 'ca_header2'], ['ca_value1', 'ca_value2']]
 """
     # pylint: disable=invalid-name
     # pylint: disable=too-many-branches
     if not self.cas_headers_and_values:
         selenium_utils.wait_for_js_to_load(self._driver)
         self.cas_headers_and_values = self._driver.find_elements(
             *self._locators.CAS_HEADERS_AND_VALUES)
     if len(self.cas_headers_and_values) > 1:
         list_text_cas_scopes = []
         for scope in self.cas_headers_and_values:
             ca_header_text = scope.text.splitlines()[0]
             if any(
                     unicode(ca_type.upper()) in ca_header_text for ca_type
                     in element.AdminWidgetCustomAttributes.ALL_CA_TYPES):
                 if len(scope.text.splitlines()) >= 2:
                     if scope.text.splitlines()[1].strip():
                         list_text_cas_scopes.append(
                             [ca_header_text,
                              scope.text.splitlines()[1]])
                     else:
                         list_text_cas_scopes.append([ca_header_text, None])
                 if len(scope.text.splitlines()) == 1:
                     if (element.AdminWidgetCustomAttributes.CHECKBOX.upper(
                     ) in ca_header_text):
                         list_text_cas_scopes.append([
                             ca_header_text,
                             unicode(
                                 int(
                                     base.Checkbox(
                                         self._driver,
                                         scope.find_element(
                                             *self._locators.CAS_CHECKBOXES)
                                     ).is_element_checked()))
                         ])
                     else:
                         list_text_cas_scopes.append([ca_header_text, None])
         cas_headers, _cas_values = zip(*list_text_cas_scopes)
         # convertation
         cas_values = []
         for ca_val in _cas_values:
             if ca_val is None:
                 cas_values.append(None)
             elif ca_val == roles.DEFAULT_USER:
                 # Example User
                 cas_values.append(
                     unicode(objects.get_singular(objects.PEOPLE).title()))
             elif "/" in ca_val and len(ca_val) == 10:
                 # Date
                 _date = ca_val.split("/")
                 cas_values.append(
                     unicode("{y}-{m}-{d}".format(y=_date[2],
                                                  m=_date[0],
                                                  d=_date[1])))
             else:
                 # Other
                 cas_values.append(ca_val)
         return cas_headers, cas_values
     else:
         return [None, None]
Beispiel #9
0
 def __init__(self, driver):
     super(CloneAuditModal, self).__init__(driver)
     self.title_modal = base.Label(driver, self._locators.MODAL_TITLE)
     self.checkbox_clone_asmt_tmpls = base.Checkbox(
         driver, self._locators.CHECKBOX_CLONE_ASMT_TMPLS)
     self.button_clone = base.Button(driver, self._locators.BUTTON_CONFIRM)