Beispiel #1
0
 def set_input(self, use_case):
     """
     On opened use case insert input
     :param use_case: Contains input data to insert
     :type: UseCase
     """
     # log.info("Set input in use case {}".format(use_case))
     wait_until(lambda: self.browser.find_element_by_name("title"), 10)
     self.browser.find_element_by_name("title").clear()
     self.browser.find_element_by_name("title").send_keys(use_case.title)
     self.browser.find_element_by_name("description").clear()
     self.browser.find_element_by_name("description").send_keys(
         use_case.description)
     self.browser.find_element_by_name("expected_result").clear()
     self.browser.find_element_by_name("expected_result").send_keys(
         use_case.expected_result)
     steps = self.browser.find_elements_by_css_selector(
         "input[placeholder*='* Use case step']")
     if len(steps) < len(use_case.steps):
         add_number = len(use_case.steps) - len(steps)
         self._add_step(add_number)
     elif len(steps) > len(use_case.steps):
         remove_number = len(steps) - len(use_case.steps)
         for i in range(remove_number):
             self._remove_step(i)
     # log.screenshot("Number of steps set. Number is: {}".format(len(use_case.steps)))
     self._input_steps(use_case.steps)
Beispiel #2
0
 def go_back(self):
     # log.info("Go back to use cases page")
     wait_until(
         lambda: self.browser.find_element_by_css_selector(
             "a[href='/use-cases']"), 10)
     self.browser.find_element_by_css_selector(
         "a[href='/use-cases']").click()
     wait_until(lambda: "//b[text()='Use Cases']", 10)
     time.sleep(
         1
     )  # this waiting is added because test fails if this line does not exist for some reason
Beispiel #3
0
 def number_of_use_case(self, title):
     # log.info("Get number of use case: {}".format(title))
     number = 0
     wait_until(
         lambda: self.browser.find_element_by_class_name("list-group"), 10)
     use_case_list = self.browser.find_element_by_css_selector("div[class*='list-group']") \
         .find_elements_by_tag_name("a")
     for ucl in use_case_list:
         if title.lower() == ucl.text.lower():
             number += 1
     # log.info("Number of use cases is: {}".format(number))
     return number
Beispiel #4
0
 def submit_use_case(self):
     """
     Click on submit on create use case page
     """
     # log.info("Click on submit use case")
     wait_until(
         lambda: self.browser.find_element_by_css_selector(
             "button[type='submit']"), 10)
     self.browser.find_element_by_css_selector(
         "button[type='submit']").click()
     wait_until(
         lambda: self.browser.find_element_by_css_selector(
             "a[data-testid='create_use_case_btn']"), 10)
Beispiel #5
0
 def open_use_cases_page(self):
     """
     From dashboard opens use case page
     """
     # log.info(Open use cases page)
     wait_until(
         lambda: self.browser.find_element_by_xpath(
             "//*[contains(text(),'{}')]".format("se cases")), 10)
     self.browser.find_element_by_xpath(
         "//*[contains(text(),'{}')]".format("se cases")).click()
     wait_until(
         lambda: self.browser.find_element_by_css_selector(
             "a[data-testid='create_use_case_btn'"), 10)
Beispiel #6
0
 def create_use_case(self):
     """
     Click on button for create use case
     """
     # log.info("Click on create use case button")
     wait_until(
         lambda: self.browser.find_element_by_css_selector(
             "a[data-testid='create_use_case_btn']"), 10)
     self.browser.find_element_by_css_selector(
         "a[data-testid='create_use_case_btn']").click()
     wait_until(
         lambda: self.browser.find_element_by_xpath(
             "//*[contains(text(), 'New Use Case')]"), 10)
Beispiel #7
0
 def delete_use_case(self, title):
     """
     Deletes use case with given title
     """
     # log.info("Delete use case {}".format(title))
     if self.open_use_case(title):
         time.sleep(2)
         self.browser.find_element_by_css_selector(
             "button[aria-label='delete-button']").click()
         time.sleep(2)
         self.browser.find_element_by_xpath(
             "//button[text()='Delete']").click()
         wait_until(
             lambda: self.browser.find_element_by_class_name("list-group"),
             10)
         # log.screenshot("Use case is deleted")
     else:
         assert False, "Use case does not exist"
         pass
Beispiel #8
0
 def open_use_case(self, title):
     """
     From use cases page opens use case with given title
     :param driver: webdriver used for browser starting
     """
     # log.info("Open use case: {}".format(title))
     wait_until(
         lambda: self.browser.find_element_by_class_name("list-group"), 10)
     use_case_list = self.browser.find_element_by_css_selector("div[class*='list-group']")\
         .find_elements_by_tag_name("a")
     for ucl in use_case_list:
         if title.lower() == ucl.text.lower():
             ucl.click()
             wait_until(
                 lambda: self.browser.find_element_by_xpath(
                     "//*[contains(text(), 'Edit Use Case')]"), 10)
             # log.screenshot("Use case opened")
             return True
     # log.info("Use case {} does not exist".format(title))
     return False
Beispiel #9
0
 def get_input(self):
     """
     From opened use case inputs, creates UseCase object
     :return: All input fields from opened use case
     :type: UseCase
     """
     # log.info("Get input from opened use case")
     wait_until(lambda: self.browser.find_element_by_name("title"), 10)
     title = self.browser.find_element_by_name("title").get_attribute(
         'value')
     description = self.browser.find_element_by_name("description").text
     expected_result = self.browser.find_element_by_name(
         "expected_result").get_attribute('value')
     steps = self.browser.find_elements_by_css_selector(
         "input[placeholder*='* Use case step']")
     steps_list = []
     for s in steps:
         steps_list.append(s.get_attribute("value"))
     use_case = UseCase(title, description, expected_result, steps_list)
     # log.screenshot(use_case)
     return use_case
Beispiel #10
0
 def login(self, username, password):
     """
     Login with given username and password
     """
     # <log.info("Open login page")>
     wait_until(
         lambda: self.browser.find_element_by_css_selector(
             "a[href='/login']"), 10)
     self.browser.find_element_by_css_selector("a[href='/login']").click()
     wait_until(lambda: self.browser.find_element_by_name("email"), 10)
     #<log.screenshot("Login page is opened. Insert {0} and {1}".format(username, password))>
     self.browser.find_element_by_name("email").send_keys(username)
     self.browser.find_element_by_name("password").send_keys(password)
     self.browser.find_element_by_css_selector(
         "button[type='submit']").click()
     wait_until(
         lambda: len(
             self.browser.find_elements_by_css_selector(
                 "button[type='submit']")) == 0, 10)