Exemple #1
0
 def submit(self):
     # Это всё для Chrome
     actions = Actions(self.driver)
     WebDriverWait(self.driver, conf.TIMEOUT, conf.POLL_FREQUENCY).until(
         lambda d: d.find_element_by_xpath(self.CREATE_BUTTON).is_enabled())
     create_button = self.driver.find_element_by_xpath(self.CREATE_BUTTON)
     actions.execute_script('window.scrollTo(0, {});'.format(
         create_button.location['y']))
     actions.wait_and_click(By.XPATH, self.CREATE_BUTTON)
Exemple #2
0
 def list_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.LIST)
Exemple #3
0
 def get_text(self):
     return Actions(self.driver).wait_and_get_text(By.XPATH, self.TEXT)
Exemple #4
0
    def add_poll(self, question, *answers):
        actions = Actions(self.driver)
        actions.click_to_element(By.XPATH, self.ADD_POLL_CHECKBOX)
        actions.send_keys_to_elem_and_perform(By.XPATH, self.QUESTION_POLL,
                                              question)

        count = len(answers)
        for index in range(count):
            answer_xpath = self.ANSWEAR_POLL.format(index)
            if not actions.element_is_exist(By.XPATH, answer_xpath):
                answer_xpath += '[2]'
                actions.click_and_wait(By.XPATH, self.ADD_OPTION_ANSWER,
                                       By.XPATH, answer_xpath)
            actions.send_keys_to_elem_and_perform(By.XPATH, answer_xpath,
                                                  answers[index])
Exemple #5
0
 def insert_image(self, url, align='', description='', as_link=False):
     actions = Actions(self.driver)
     actions.wait_and_click(By.XPATH, self.ADD_IMAGE)
     WebDriverWait(self.driver, conf.TIMEOUT, conf.POLL_FREQUENCY).until(
         expected_conditions.presence_of_element_located(
             (By.XPATH, self.WINDOW_UPLOAD)))
     actions.wait_and_click(By.XPATH, self.FROM_INTERNET)
     actions.clear(By.XPATH, self.INPUT_IMG_URL)
     actions.send_keys_to_elem_and_perform(By.XPATH, self.INPUT_IMG_URL,
                                           url)
     align_selector = Select(
         self.driver.find_element_by_xpath(self.ALIGN_SELECT_FROM_INTERNET))
     align_selector.select_by_value(align)
     actions.wait_and_click(By.XPATH, self.IMAGE_DESCRIPTION_FROM_INTERNET)
     actions.send_keys_and_perform(*description)
     if as_link:
         actions.wait_and_click(
             By.XPATH, self.SUBMIT_INSERT_IMAGE_AS_LINK_FROM_INTERNET)
     else:
         actions.wait_and_click(By.XPATH,
                                self.SUBMIT_UPLOAD_IMAGE_FROM_INTERNET)
     WebDriverWait(self.driver, conf.TIMEOUT, conf.POLL_FREQUENCY).until(
         lambda d: description in d.find_element_by_xpath(
             self.MAIN_TEXT).get_attribute('value'))
Exemple #6
0
 def add_link_to_main_text(self, url, name):
     actions = Actions(self.driver)
     actions.wait_and_click(By.XPATH, self.ADD_LINK)
     actions.wait_alert()
     actions.set_text_to_alert(url)
     actions.send_keys_and_perform(name)
Exemple #7
0
 def forbid_comment_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.FORBID_COMMENT)
Exemple #8
0
 def add_additional_answer_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.ADD_OPTION_ANSWER)
Exemple #9
0
 def h6_text_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.H6_BUTTON)
Exemple #10
0
 def get_poll_answers(self):
     actions = Actions(self.driver)
     elements = actions.get_list_elements(By.XPATH, self.POLL_ANSWER)
     return actions.get_list_text_from_list_elements(*elements)
Exemple #11
0
 def has_add_comment_btn(self):
     return Actions(self.driver).element_is_exist(By.XPATH,
                                                  self.ADD_COMMENT)
Exemple #12
0
 def get_inner_html_text(self):
     return Actions(self.driver).wait_and_get_attribute(
         By.XPATH, self.TEXT, 'innerHTML')
Exemple #13
0
 def delete(self):
     actions = Actions(self.driver)
     actions.click_to_element(By.XPATH, self.DELETE_BUTTON)
     actions.click_to_element(By.XPATH, self.DELETE_BUTTON_CONFIRM)
Exemple #14
0
 def open_blog(self):
     Actions(self.driver).click_to_element(By.XPATH, self.BLOG)
Exemple #15
0
 def numbered_list_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.NUMBERED_LIST)
Exemple #16
0
 def bold_text_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.BOLD_TEXT)
Exemple #17
0
 def add_poll_checkbox_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.ADD_POLL_CHECKBOX)
Exemple #18
0
 def italic_text_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.ITALIC_TEXT)
Exemple #19
0
 def delete_additional_answer_click(self):
     Actions(self.driver).wait_and_click(By.XPATH,
                                         self.DELETE_OPTION_ANSWER)
Exemple #20
0
 def strikethrough_text_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.STRIKETHROUGH_TEXT)
Exemple #21
0
 def select_main_text(self):
     Actions(self.driver).select_text(By.XPATH, self.MAIN_TEXT)
Exemple #22
0
 def underline_text_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.UNDERLINE_TEXT)
Exemple #23
0
 def add_user(self, name):
     actions = Actions(self.driver)
     actions.wait_and_click(By.XPATH, self.ADD_USER)
     actions.wait_and_click(By.XPATH, self.SEARCH_USER_POPUP)
     actions.send_keys_and_perform(name)
     actions.submit(By.XPATH, self.SEARCH_USER_POPUP)
     choose_user = '******' + name + '")]'
     WebDriverWait(self.driver, conf.TIMEOUT, conf.POLL_FREQUENCY).until(
         expected_conditions.presence_of_element_located(
             (By.XPATH, choose_user)))
     actions.wait_and_click(By.XPATH, choose_user)
     WebDriverWait(self.driver, conf.TIMEOUT, conf.POLL_FREQUENCY).until(
         lambda d: name in d.find_element_by_xpath(self.MAIN_TEXT
                                                   ).get_attribute('value'))
Exemple #24
0
 def quote_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.QUOTE)
Exemple #25
0
 def upload_image(self, path_to_file, align='', description=''):
     actions = Actions(self.driver)
     actions.wait_and_click(By.XPATH, self.ADD_IMAGE)
     WebDriverWait(self.driver, conf.TIMEOUT, conf.POLL_FREQUENCY).until(
         expected_conditions.presence_of_element_located(
             (By.XPATH, self.WINDOW_UPLOAD)))
     actions.wait_and_click(By.XPATH, self.FROM_PC)
     actions.send_keys_to_elem_and_perform(By.XPATH, self.INPUT_IMG_FILE,
                                           path_to_file)
     align_selector = Select(
         self.driver.find_element_by_xpath(self.ALIGN_SELECT_FROM_PC))
     align_selector.select_by_value(align)
     actions.wait_and_click(By.XPATH, self.IMAGE_DESCRIPTION_FROM_PC)
     actions.send_keys_and_perform(*description)
     actions.wait_and_click(By.XPATH, self.SUBMIT_IMAGE_FILE)
     WebDriverWait(self.driver, conf.TIMEOUT, conf.POLL_FREQUENCY).until(
         lambda d: description in d.find_element_by_xpath(
             self.MAIN_TEXT).get_attribute('value'))
Exemple #26
0
 def code_click(self):
     Actions(self.driver).wait_and_click(By.XPATH, self.CODE)
Exemple #27
0
 def get_info(self):
     return Actions(self.driver).wait_and_get_text(By.XPATH,
                                                   self.INFO_BLOCK)
Exemple #28
0
 def get_title(self):
     return Actions(self.driver).wait_and_get_text(By.XPATH, self.TITLE)