Exemplo n.º 1
0
 def tearDown(self):
     """
     Default teardown method for all scripts. If run through Sauce Labs OnDemand, the job name, status and tags
     are updated. Also the video and server log are downloaded if so configured.
     """
     SaunterWebDriver.quit()
     self.assertEqual([], self.verificationErrors)
Exemplo n.º 2
0
 def wait_for_value_changed(self, locator, text):
     e = SaunterWebDriver.find_element_by_locator(locator)
     for i in range(timeout_seconds):
         try:
             if len(e.text.strip()) != 0 and e.text != text:
                 return True
         except StaleElementReferenceException, e:
             e = SaunterWebDriver.find_element_by_locator(locator)
         finally:
Exemplo n.º 3
0
 def is_element_available(self, locator):
     """
     Synchronization method for making sure the element we're looking for is not only on the page,
     but also visible -- since Se will happily deal with things that aren't visible.
     
     Use this instead of is_element_present most of the time.
     """
     if SaunterWebDriver.is_element_present(locator):
         if SaunterWebDriver.is_visible(locator):
             return True
         else:
             return False
     else:
         return False
Exemplo n.º 4
0
 def __get__(self, obj, cls=None):
     try:
         e = SaunterWebDriver.find_element_by_locator(self.locator)
         return int(e.text)
     except AttributeError as e:
         if str(e) == "'SeleniumWrapper' object has no attribute 'connection'":
             pass
         else:
             raise e
     except ElementNotFound as e:
         msg = "Element %s was not found. It is used in the %s page object in the %s module." % (self.locator, obj.__class__.__name__, self.__module__)
         raise ElementNotFound(msg)
Exemplo n.º 5
0
    def wait_for_element_not_present(self, locator):
        """
        Synchronization helper to wait until some element is removed from the page 

        :raises: ElementVisiblityTimeout
        """
        for i in range(timeout_seconds):
            if SaunterWebDriver.is_element_present(locator):
                time.sleep(1)
            else:
                break
        else:
            raise ElementVisiblityTimeout("%s presence timed out" % locator)
        return True
Exemplo n.º 6
0
    def wait_for_hidden(self, locator):
        """
        Synchronization to deal with elements that are present, but are visibility until some action
        triggers their hidden-ness.

        :raises: ElementVisiblityTimeout=
        """
        for i in range(timeout_seconds):
            if SaunterWebDriver.is_visible(locator):
                time.sleep(1)
            else:
                break
        else:
            raise ElementVisiblityTimeout("%s visibility timed out" % locator)
        return True
Exemplo n.º 7
0
 def __get__(self, obj, cls=None):
     try:
         e = SaunterWebDriver.find_element_by_locator(self.locator)
         return int(e.text)
     except AttributeError as e:
         if str(
                 e
         ) == "'SeleniumWrapper' object has no attribute 'connection'":
             pass
         else:
             raise e
     except ElementNotFound as e:
         msg = "Element %s was not found. It is used in the %s page object in the %s module." % (
             self.locator, obj.__class__.__name__, self.__module__)
         raise ElementNotFound(msg)
Exemplo n.º 8
0
    def wait_for_text(self, locator, text):
        """
        Synchronization on some text being displayed in a particular element.

        :raises: ElementVisiblityTimeout
        """
        for i in range(timeout_seconds):
            try:
                e = SaunterWebDriver.find_element_by_locator(locator)
                if e.text == text:
                    break
            except:
                pass
            time.sleep(1)
        else:
            raise ElementTextTimeout("%s value timed out" % locator)
        return True
Exemplo n.º 9
0
 def wait_for_visible(self, locator):
     """
     Synchronization to deal with elements that are present, but are disabled until some action
     triggers their visibility.
     
     :raises: ElementVisiblityTimeout        
     """
     for i in range(timeout_seconds):
         try:
             if SaunterWebDriver.is_visible(locator):
                 break
         except:
             pass
         time.sleep(1)
     else:
         raise ElementVisiblityTimeout("%s visibility timed out" % locator)
     return True
Exemplo n.º 10
0
 def __set__(self, obj, val):
     e = SaunterWebDriver.find_element_by_locator(self.locator)
     e.send_keys(val)
Exemplo n.º 11
0
 def get_meta_element(self, name):
     return SaunterWebDriver.find_element_by_locator('css=meta[name="%s"]' % name)
Exemplo n.º 12
0
 def get_meta_elements(self):
     return SaunterWebDriver.find_elements_by_locator("tag=meta")
Exemplo n.º 13
0
 def is_collar_selected(self, style):
     if SaunterWebDriver.is_element_present("%s .sl-deSel" % locators["collar style"].replace("REPLACE", style)):
         return False
     return True
Exemplo n.º 14
0
 def change_collar_style(self, style):
     before = self.results;
     SaunterWebDriver.find_element_by_locator(locators["collar style"].replace("REPLACE", style)).click()
     self.wait_for_value_changed(locators["results"], before)
Exemplo n.º 15
0
 def __set__(self, obj, val):
     e = SaunterWebDriver.find_element_by_locator(self.locator)
     e.send_keys(val)