Esempio n. 1
0
 def get_row_by_index(self,
                      index: int,
                      wait_time: int = element_load_time) -> T:
     Log.info("Getting row by index %s from the table: %s" %
              (index, self.name))
     rows = self.get_content(wait_time=wait_time)
     return rows[index]
Esempio n. 2
0
 def exists(self, wait_time: int = 0) -> bool:
     Log.info("Checking if '%s' element exists" % self.name)
     try:
         self.wait_for.presence_of_element_located(wait_time)
         return True
     except (NoSuchElementException, TimeoutException):
         return False
Esempio n. 3
0
 def alert_is_present(self,
                      wait_time: int = page_load_time,
                      poll_frequency=POLL_FREQUENCY,
                      ignored_exceptions=None):
     Log.info('Expect an alert to be present.')
     return self.condition(wait_time, alert_is_present(), poll_frequency,
                           ignored_exceptions)
 def drag_and_drop(self, destination):
     Log.info("Drag and Drop on %s" % self.name)
     element = self.get_element()
     if not isinstance(destination, WebElement):
         destination = destination.get_element()
     ActionChains(element.parent).drag_and_drop(element,
                                                destination).perform()
 def wait_for_text_to_be_present_in_element(
         self, wait_time: int = element_load_time, text: str = ""):
     Log.info('Waiting for the text %s to be present' % self.name)
     x = WebDriverWait(self.get_element().parent, wait_time).until(
         expected_conditions.text_to_be_present_in_element(
             self.locator, text))
     return x
Esempio n. 6
0
 def title_is(self,
              title: str,
              wait_time: int = page_load_time,
              poll_frequency=POLL_FREQUENCY,
              ignored_exceptions=None):
     Log.info('An expectation for checking the title of a page.')
     return self.condition(wait_time, title_is(title), poll_frequency,
                           ignored_exceptions)
Esempio n. 7
0
 def url_changes(self,
                 url: str,
                 wait_time: int = page_load_time,
                 poll_frequency=POLL_FREQUENCY,
                 ignored_exceptions=None):
     Log.info('An expectation for checking the current url.')
     return self.condition(wait_time, url_changes(url), poll_frequency,
                           ignored_exceptions)
Esempio n. 8
0
 def number_of_windows_to_be(self,
                             num_windows: int,
                             wait_time: int = page_load_time,
                             poll_frequency=POLL_FREQUENCY,
                             ignored_exceptions=None):
     Log.info(
         'An expectation for the number of windows to be a certain value.')
     return self.condition(wait_time, number_of_windows_to_be(num_windows),
                           poll_frequency, ignored_exceptions)
Esempio n. 9
0
 def element_to_be_clickable(self,
                             wait_time: int = element_load_time,
                             poll_frequency=POLL_FREQUENCY,
                             ignored_exceptions=None):
     Log.info(
         'An Expectation for checking an element "%s" is visible and enabled such that you can click it.'
         % self.name)
     return self.condition(wait_time, element_to_be_clickable(self.locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 10
0
 def url_contains(self,
                  url: str,
                  wait_time: int = page_load_time,
                  poll_frequency=POLL_FREQUENCY,
                  ignored_exceptions=None):
     Log.info(
         'An expectation for checking that the current url contains a case-sensitive substring.'
     )
     return self.condition(wait_time, url_contains(url), poll_frequency,
                           ignored_exceptions)
Esempio n. 11
0
 def invisibility_of_element_located(self,
                                     wait_time: int = element_load_time,
                                     poll_frequency=POLL_FREQUENCY,
                                     ignored_exceptions=None):
     Log.info(
         'An Expectation for checking that an element "%s" is either invisible or not present on the DOM.'
         % self.name)
     return self.condition(wait_time,
                           invisibility_of_element_located(self.locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 12
0
 def visibility_of_any_elements_located(self,
                                        wait_time: int = element_load_time,
                                        poll_frequency=0.5,
                                        ignored_exceptions=None):
     Log.info(
         'An expectation for checking that there is at least one element "%s" visible on a web page.'
         % self.name)
     return self.condition(wait_time,
                           visibility_of_any_elements_located(self.locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 13
0
 def presence_of_all_elements_located(self,
                                      wait_time: int = element_load_time,
                                      poll_frequency=POLL_FREQUENCY,
                                      ignored_exceptions=None):
     Log.info(
         'An expectation for checking that there is at least one element "%s" present on a web page.'
         % self.name)
     return self.condition(wait_time,
                           presence_of_all_elements_located(self.locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 14
0
 def element_located_to_be_selected(self,
                                    wait_time: int = element_load_time,
                                    poll_frequency=POLL_FREQUENCY,
                                    ignored_exceptions=None):
     Log.info(
         'An expectation for the element "%s" to be located is selected.' %
         self.name)
     return self.condition(wait_time,
                           element_located_to_be_selected(self.locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 15
0
 def staleness_of(self,
                  wait_time: int = element_load_time,
                  poll_frequency=POLL_FREQUENCY,
                  ignored_exceptions=None):
     Log.info(
         'Wait until an element is no longer attached to the DOM. "%s" is the element to wait for'
         % self.name)
     return self.condition(wait_time,
                           staleness_of(self.presence_of_element_located()),
                           poll_frequency, ignored_exceptions)
Esempio n. 16
0
 def visibility_of_all_elements_located(self,
                                        wait_time: int = element_load_time,
                                        poll_frequency=0.5,
                                        ignored_exceptions=None):
     Log.info(
         'An expectation for checking that all elements "%s" are present on the DOM of a page and visible.'
         % self.name)
     return self.condition(wait_time,
                           visibility_of_all_elements_located(self.locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 17
0
 def visibility_of(self,
                   wait_time: int = element_load_time,
                   poll_frequency=POLL_FREQUENCY,
                   ignored_exceptions=None):
     Log.info(
         'Waiting for the existing "%s" element on the page to be visible.'
         % self.name)
     return self.condition(
         wait_time, visibility_of(self.presence_of_element_located()),
         poll_frequency, ignored_exceptions)
Esempio n. 18
0
 def presence_of_element_located(self,
                                 wait_time: int = element_load_time,
                                 poll_frequency=POLL_FREQUENCY,
                                 ignored_exceptions=None):
     Log.info(
         'An expectation for checking that an element "%s" is present on the DOM of a page.'
         % self.name)
     return self.condition(wait_time,
                           presence_of_element_located(self.locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 19
0
 def new_window_is_opened(self,
                          current_handles: list,
                          wait_time: int = page_load_time,
                          poll_frequency=POLL_FREQUENCY,
                          ignored_exceptions=None):
     Log.info(
         'An expectation that a new window will be opened and have the number of windows handles increase'
     )
     return self.condition(wait_time, new_window_is_opened(current_handles),
                           poll_frequency, ignored_exceptions)
Esempio n. 20
0
 def text_to_be_present_in_element_value(self,
                                         text: str,
                                         wait_time: int = element_load_time,
                                         poll_frequency=POLL_FREQUENCY,
                                         ignored_exceptions=None):
     Log.info(
         'Checking if the given text is present in the element\'s locator "%s", text.'
         % self.name)
     return self.condition(
         wait_time, text_to_be_present_in_element_value(self.locator, text),
         poll_frequency, ignored_exceptions)
Esempio n. 21
0
 def element_to_be_selected(self,
                            wait_time: int = element_load_time,
                            poll_frequency=POLL_FREQUENCY,
                            ignored_exceptions=None):
     Log.info(
         'An expectation for checking the selection "%s" is selected.' %
         self.name)
     return self.condition(
         wait_time,
         element_to_be_selected(self.presence_of_element_located()),
         poll_frequency, ignored_exceptions)
Esempio n. 22
0
 def number_of_elements(self,
                        elements_count: int,
                        wait_time: int = element_load_time,
                        poll_frequency=0.5,
                        ignored_exceptions=None):
     Log.info(
         'An expectation for checking that number elements "%s" are present on the DOM of a page.'
         % self.name)
     return self.condition(
         wait_time, lambda driver: len(driver.find_elements(*self.locator))
         == elements_count, poll_frequency, ignored_exceptions)
Esempio n. 23
0
 def frame_to_be_available_and_switch_to_it(self,
                                            locator: Locator,
                                            wait_time: int = page_load_time,
                                            poll_frequency=POLL_FREQUENCY,
                                            ignored_exceptions=None):
     Log.info(
         'An expectation for checking whether the given frame "%s" is available to switch to.'
         % str(locator))
     return self.condition(wait_time,
                           frame_to_be_available_and_switch_to_it(locator),
                           poll_frequency, ignored_exceptions)
Esempio n. 24
0
 def exists(
         self,
         wait_time: int = 0,
         condition: expected_conditions = presence_of_element_located
 ) -> bool:
     Log.info("Checking if '%s' element exists" % self.name)
     try:
         self.get_element(condition=condition, wait_time=wait_time)
         return True
     except (NoSuchElementException, TimeoutException):
         return False
Esempio n. 25
0
 def element_selection_state_to_be(self,
                                   is_selected: bool,
                                   wait_time: int = element_load_time,
                                   poll_frequency=POLL_FREQUENCY,
                                   ignored_exceptions=None):
     Log.info(
         'An expectation for checking if the given element "%s" is selected.'
         % self.name)
     return self.condition(
         wait_time,
         element_selection_state_to_be(self.presence_of_element_located(),
                                       is_selected), poll_frequency,
         ignored_exceptions)
Esempio n. 26
0
 def element_located_selection_state_to_be(
         self,
         is_selected: bool,
         wait_time: int = element_load_time,
         poll_frequency=POLL_FREQUENCY,
         ignored_exceptions=None):
     Log.info(
         'An expectation to locate an element "%s" and check if the selection state specified is in that '
         'state.' % self.name)
     return self.condition(
         wait_time, element_selection_state_to_be(self.locator,
                                                  is_selected),
         poll_frequency, ignored_exceptions)
Esempio n. 27
0
 def get_column_values(self,
                       column_name: str,
                       wait_time: int = element_load_time) -> T:
     Log.info("Getting column %s values from the table: %s" %
              (column_name, self.name))
     column = []
     end_time = time.time() + wait_time
     while True:
         content = self.get_content()
         if len(content) > 0:
             for row in content:
                 column.append(
                     getattr(row, column_name).get_attribute('textContent'))
             return column
         if time.time() > end_time:
             break
     return None
Esempio n. 28
0
 def send_logs_to_test_rail(self, run_id, item, outcome):
     test_case_ids = self.get_test_ids(item)
     if test_case_ids:
         for test_id in test_case_ids:
             try:
                 actual_result = outcome.get_result()
                 actual_outcome = actual_result.outcome
                 if hasattr(item, 'execution_count'):
                     if item.execution_count > 1 and actual_outcome == 'passed':
                         actual_outcome = 'flaky'
                 self.service.add_result_for_case(
                     run_id=run_id,
                     case_id=test_id,
                     status=self.get_result_from_string(actual_outcome),
                     comment=actual_result.capstderr)
             except APIError as e:
                 Log.info(e)
                 continue
Esempio n. 29
0
 def get_row_by_column_value(self,
                             column_name: str,
                             value: str,
                             wait_time: int = element_load_time) -> T:
     Log.info("Getting row by column %s with value %s from the table: %s" %
              (column_name, value, self.name))
     end_time = time.time() + wait_time
     while True:
         content = self.get_content()
         for row in content:
             if getattr(row, column_name).exists():
                 row_value = getattr(row, column_name).text
                 Log.info("Actual text: %s" % row_value)
                 if row_value == value:
                     return row
         if self.next_page():
             return self.get_row_by_column_value(column_name, value,
                                                 wait_time)
         if time.time() > end_time:
             break
     return None
Esempio n. 30
0
 def get_row_index_by_column_values(
         self,
         column_name: str,
         values: list,
         wait_time: int = element_load_time) -> T:
     Log.info("Getting row by column %s with value %s from the table: %s" %
              (column_name, values, self.name))
     end_time = time.time() + wait_time
     while True:
         content = self.get_content()
         for i in range(len(content)):
             if getattr(content[i], column_name).exists():
                 row_value = getattr(content[i], column_name).text
                 Log.info("Actual text: %s" % row_value)
                 if row_value in values:
                     return i
         if self.next_page():
             return self.get_row_index_by_column_values(
                 column_name, values, wait_time)
         if time.time() > end_time:
             break
     return None