Ejemplo n.º 1
0
    def set_label(self, label, index=None):
        try:
            elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.label)
        except NoSuchElementException:
            return None

        if not elems:
            self.add_url_field()
            elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.label)

        if not index:
            for elem in elems:
                if elem.get_attribute('value') == '':
                    BasePage.type(self, label, elem)
                    return HttpTest
            self.add_url_field()
            elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.label)
            BasePage.type(self, label, elems[len(elems) - 1])
            return HttpTest

        if index:
            rows_count = len(elems)
            if len(elems) < index:
                while rows_count < index:
                    self.add_url_field()
                    rows_count += 1
                elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.label)
                BasePage.type(self, label, elems[index - 1])
            else:
                BasePage.type(self, label, elems[index - 1])
        return HttpTest
Ejemplo n.º 2
0
    def delete_url_field(self, index=None):
        count = self.get_fields_count()
        if count > 0:
            elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.delete_row_icon)
            # if no 'index' param - delete the last field
            if index is None:
                elems[len(elems) - 1].click()
            else:
                if index >= len(elems):
                    raise NoSuchElementException(
                        "You specify the field does not exist. Impossible to delete this Url field")
                else:
                    elems[index - 1].click()

        BasePage.wait_page(self)
        assert self.get_fields_count() == count - 1
Ejemplo n.º 3
0
    def set_url(self, url, index=None, type_test=None):
        try:
            elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.url_field)
            selects = BasePage.find_elements(self, By.CSS_SELECTOR, self.type_select)
        except NoSuchElementException:
            return None

        if not elems:
            self.add_url_field()
            elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.url_field)

        if not index:
            i = 0
            while i < len(elems):
                if elems[i].get_attribute('value') == '':
                    BasePage.type(self, url, elems[i])
                    if type_test:
                        selects = BasePage.find_elements(self, By.CSS_SELECTOR, self.type_select)
                        BasePage.select_option(self, type_test, selects[i])
                    return HttpTest
                i += 1
            self.add_url_field()
            elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.url_field)
            selects = BasePage.find_elements(self, By.CSS_SELECTOR, self.type_select)
            BasePage.type(self, url, elems[len(elems) - 1])
            BasePage.select_option(self, type_test, selects[len(selects) - 1])
            return HttpTest

        if index:
            rows_count = len(elems)
            if len(elems) < index:
                while rows_count < index:
                    self.add_url_field()
                    rows_count += 1
                elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.url_field)
                selects = BasePage.find_elements(self, By.CSS_SELECTOR, self.type_select)
                BasePage.type(self, url, elems[index - 1])
                BasePage.select_option(self, type_test, selects[index - 1])
            else:
                BasePage.type(self, url, elems[index - 1])
                BasePage.select_option(self, type_test, selects[index - 1])
        return HttpTest
Ejemplo n.º 4
0
 def verify_request_type(self, test_type, index):
     selects = BasePage.find_elements(self, By.CSS_SELECTOR, self.type_select)
     selected = BasePage.selected_option(self, selects[index - 1])
     assert selected.__eq__(test_type), 'Incorrect request type was selected'