Beispiel #1
0
    def upload(self, file_path):
        elem = BasePage.find_element(self, By.CSS_SELECTOR, 'div.files-container input')
        get_driver(self).execute_script("arguments[0].className = 'file-input';", elem)
        get_driver(self).execute_script("arguments[0].style.visibility = 'visible';", elem)
        elem.send_keys([file_path])

        assert BasePage.is_element_present(self, By.CSS_SELECTOR, self.delete_button), 'Failed to upload file'
Beispiel #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
Beispiel #3
0
    def type_header(self, header, index=None):
        if index is None:
            index = 1

        self.open_more_options_menu(index)

        vals = header.values()
        keys = header.keys()
        length = len(vals)

        count = BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) +
                                        self.header_name_field)
        while count <= length:
            self.add_header_row(index)
            count += 1

        i = 0
        while i < len(vals):
            name = BasePage.find_element(self, By.CSS_SELECTOR, self.row_header_prefix.format(index, i + 1) +
                                         self.header_name_field)
            value = BasePage.find_element(self, By.CSS_SELECTOR, self.row_header_prefix.format(index, i + 1) +
                                          self.header_value_field)
            BasePage.type(self, keys[i], name)
            BasePage.type(self, vals[i], value)
            i += 1
Beispiel #4
0
    def verify_more_options_is_opened(self, index=None, opened=None):
        if index is None:
            index = 1
        if opened is None:
            opened = True

        present = BasePage.is_element_present(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) +
                                              self.add_header_button)
        return present if opened else not present
Beispiel #5
0
 def add_header_row(self, index=None):
     if index is None:
         index = 1
     self.open_more_options_menu(index)
     count = BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) +
                                     self.header_name_field)
     BasePage.click(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.add_header_button)
     BasePage.wait_page(self)
     assert BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) +
                                    self.header_name_field) == count + 1, 'Failed to add new row'
Beispiel #6
0
    def delete_header_row(self, index=None, header_index=None):
        if index is None:
            index = 1
        if header_index is None:
            header_index = 1
        self.open_more_options_menu(index)
        count = BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) +
                                        self.header_name_field)
        if count >= header_index and count is not 0:
            BasePage.click(self, By.CSS_SELECTOR, self.row_header_prefix.format(index, header_index) +
                           self.header_delete_row)
            BasePage.wait_page(self)
        else:
            raise NoSuchElementException('There is no such header')

        assert BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) +
                                       self.header_name_field) == count - 1, 'Failed to delete header row'
Beispiel #7
0
 def verify_test_type(self):
     text = BasePage.get_text(self, By.CSS_SELECTOR, TestConfiguration().test_type_title)
     return self.test_type.__eq__(text)
Beispiel #8
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
Beispiel #9
0
 def add_url_field(self):
     count = self.get_fields_count()
     BasePage.click(self, By.CSS_SELECTOR, self.add_row_button)
     BasePage.wait_page(self)
     assert self.get_fields_count() == count + 1
Beispiel #10
0
 def test_slot_present(self):
     assert BasePage.count_elements(self, By.CSS_SELECTOR, self.url_field) > 0, 'Failed to present url field'
Beispiel #11
0
 def get_fields_count(self):
     return BasePage.count_elements(self, By.CSS_SELECTOR, self.url_field)
Beispiel #12
0
 def click_more_options(self, index=None):
     if index is None:
         index = 1
     BasePage.click(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.more_options_button)
     BasePage.wait_page(self)
Beispiel #13
0
 def get_request_body(self, index):
     return BasePage.get_value(self, By.CSS_SELECTOR, self.request_body.format(index))
Beispiel #14
0
 def type_request_body(self, request_body, index):
     BasePage.type_text(self, request_body, By.CSS_SELECTOR, self.request_body.format(index))
     self.verify_request_body(request_body, index)
     return HttpTest
Beispiel #15
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'
Beispiel #16
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