示例#1
0
    def custom_is_visible(self, elem_name=None, elem_id=None, elem_xpath=None):

        if elem_name == None and elem_id == None:

            try:
                self.driver.find_element_by_xpath(elem_xpath)
            except:
                raise NoSuchElementException(
                    '1. The element with the %s XPath does not exist' %
                    elem_xpath)
            try:
                self.assertIn(
                    'block',
                    self.driver.find_element_by_xpath(
                        elem_xpath).get_attribute('style'),
                    '1.The popup Is Not visible')
            except:
                raise NoSuchAttributeException(
                    '2. The element does not have a Style Attribute')

        if elem_name == None and elem_xpath == None:

            try:
                self.driver.find_element_by_id(elem_id)
            except:
                raise NoSuchElementException(
                    '3. The element with the %s Id does not exist' % elem_id)
            try:
                self.assertIn(
                    'block',
                    self.driver.find_element_by_id(elem_id).get_attribute(
                        'style'), '1.The popup Is Not visible')
            except:
                raise NoSuchAttributeException(
                    '4. The element does not have a Style Attribute')

        if elem_xpath == None and elem_id == None:

            try:
                self.driver.find_element_by_name(elem_name)
            except:
                raise NoSuchElementException(
                    '5. The element with the %s Name does not exist' %
                    elem_name)
            try:
                self.assertIn(
                    'block',
                    self.driver.find_element_by_name(elem_name).get_attribute(
                        'style'), '1.The popup Is Not visible')
            except:
                raise NoSuchAttributeException(
                    '6. The element does not have a Style Attribute')
示例#2
0
 def get_attribute(self, name):
     """Gets the attribute value."""
     try:
         resp = self._execute(Command.GET_ELEMENT_ATTRIBUTE, {'name': name})
         return str(resp['value'])
     # FIXME: This is a hack around selenium server bad response, remove this
     #        code when it's fixed
     except AssertionError, e:
         raise NoSuchAttributeException(name)
示例#3
0
    def text(self):
        """
		Returns inner text or NoSuchElementException
		in case element is invisible or not present on the DOM
		:return:
		"""
        try:
            text = self.element.text
            return text

        except TimeoutException:
            raise NoSuchAttributeException(
                '\nERROR: The element has no attribute "text".\n'
                'LOCATOR: {}\n'.format(self.locator))
示例#4
0
 def __get_checkbox_element(self, name, groupIndex):
     '''
     Return the hj-checkbox web element
     :param groupIndex: The field group the control located in
     :param name: The control's label name
     :return: hj-checkbox element
     '''
     field_control = self.__get_field_control(name, groupIndex)
     checkbox_element = self.find_child_element(field_control,
                                                *self.__checkbox_loc)
     if checkbox_element.get_attribute("type") == "checkbox":
         return checkbox_element
     else:
         raise NoSuchAttributeException('It is not a checkbox')
    def attribute(self, attribute: str):
        """
        Returns attribute value
        :return:
        """
        try:
            atr = self.element.get_attribute(attribute)
            # print('\nattribute: {}, object: {}'.format(attribute, atr))  # debug only
            return atr

        except TimeoutException:
            raise NoSuchAttributeException(
                '\nERROR: The element has no attribute "{}".\n'
                'LOCATOR: {}\n'.format(attribute, self.locator))