예제 #1
0
 def open_todo_options(self, index, test):
     try:
         ActionChains(self.driver).context_click(
             self.get_todos()[index]).perform()
         wait_for_element_by_selector(self.driver, self.OPTION_LIST)
     except IndexError:
         test.fail('No todo was found')
예제 #2
0
 def choose_priority(self, priority):
     for priority_item in self.driver.find_elements_by_css_selector(
             self.PRIORITY_LIST_ITEM):
         if priority_item.text == priority:
             priority_item.click()
             break
     wait_for_element_by_selector(self.driver, self.PRIORITY_LIST, False)
예제 #3
0
    def delete_todos(self, test):
        try:
            self.driver.find_element_by_css_selector(
                self.PRIORITY_LIST_ITEM).click()
        except NoSuchElementException:
            pass

        # Delete all todos
        prev_length = len(self.get_todos())
        while len(self.get_todos()) != 0:
            self.open_todo_options(0, test)
            options = self.driver.find_element_by_css_selector(
                self.OPTION_LIST)
            for li in options.find_elements_by_css_selector(
                    self.TODO_POPUP_ITEM):
                if li.text == self.TODO_DELETE_TEXT:
                    li.click()
                    wait_for_element_by_selector(self.driver, self.OPTION_LIST,
                                                 False)
                    time.sleep(0.5)
                    break
            if prev_length == len(self.get_todos()):
                test.fail('Deletion failed')
            else:
                prev_length = len(self.get_todos())
예제 #4
0
 def create_todo(self, name: str, index=None):
     self.driver.find_element_by_css_selector(
         self.NEW_TODO_INPUT).send_keys(name, Keys.RETURN)
     if index is not None:
         wait_for_element_by_selector(self.driver,
                                      f'{self.TODO}:nth-child({index+1})')
     else:
         wait_for_element_by_selector(self.driver, self.TODO)
예제 #5
0
    def check_for_self(self, test):
        wait_for_element_by_selector(self.driver, self.CONTAINER)
        wait_for_element_by_selector(self.driver, self.TITLE)
        title_name = self.driver.find_element_by_css_selector(self.TITLE).text
        test.assertEqual(self.TITLE_NAME, title_name)

        current_url = self.driver.current_url
        test.assertEqual(self.FINAL_PATH, current_url)
예제 #6
0
 def set_sort(self, sort_name):
     self.open_settings()
     for setting in self.driver.find_elements_by_css_selector(
             self.SETTINGS_ITEM):
         if setting.text == self.SORT_BY_PRIORITY:
             setting.click()
             break
     wait_for_element_by_selector(self.driver, self.SETTINGS_FRAME, False)
예제 #7
0
    def check_for_self(self, test):
        test.assertEqual(self.PATH, self.driver.current_url)
        wait_for_element_by_selector(self.driver, self.CONTAINER)
        wait_for_element_by_selector(self.driver, self.TITLE)

        test.assertEqual(
            self.TITLE_TEXT,
            self.driver.find_element_by_css_selector(self.TITLE).text)
예제 #8
0
 def check_error_msg_for(self, selector, test, text):
     if text is None:
         visible = False
     else:
         visible = True
     wait_for_element_by_selector(self.driver, selector, visible)
     if visible:
         test.assertEqual(
             text,
             self.driver.find_element_by_css_selector(selector).text)
예제 #9
0
 def check_priority_list_open(self, test):
     wait_for_element_by_selector(self.driver, self.PRIORITY_LIST)
     priority_list_items = self.driver.find_elements_by_css_selector(
         self.PRIORITY_LIST_ITEM)
     test.assertEqual(len(self.PRIORITY_NAMES), len(priority_list_items))
예제 #10
0
 def open_settings(self):
     wait_for_element_by_selector(self.driver, self.SETTINGS_BUTTON)
     self.driver.find_element_by_css_selector(self.SETTINGS_BUTTON).click()
     wait_for_element_by_selector(self.driver, self.SETTINGS_FRAME)
예제 #11
0
 def check_if_dissappeared(self):
     wait_for_element_by_selector(self.driver, self.CONTAINER, False)
예제 #12
0
 def click_on(self, selector):
     wait_for_element_by_selector(self.driver, selector)
     self.driver.find_element_by_css_selector(selector).click()
예제 #13
0
 def set_input(self, selector, value):
     wait_for_element_by_selector(self.driver, selector)
     element = self.driver.find_element_by_css_selector(selector)
     element.clear()
     element.send_keys(value)
예제 #14
0
 def submit(self):
     wait_for_element_by_selector(self.driver, self.SUBMIT)
     self.driver.find_element_by_css_selector(self.SUBMIT).click()
예제 #15
0
 def open(self):
     self.driver.find_element_by_css_selector(self.LINK).click()
     wait_for_element_by_selector(self.driver, self.CONTAINER)
예제 #16
0
 def check_for_login(self, test, login):
     wait_for_element_by_selector(self.driver, self.LOGIN_LINK)
     test.assertEqual(
         login,
         self.driver.find_element_by_css_selector(self.LOGIN_LINK).text)