コード例 #1
0
ファイル: webdriver.py プロジェクト: pombredanne/py.saunter
 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)
コード例 #2
0
ファイル: page.py プロジェクト: pombredanne/py.saunter
 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:
コード例 #3
0
ファイル: page.py プロジェクト: pombredanne/py.saunter
 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
コード例 #4
0
ファイル: number.py プロジェクト: Desperado/py.saunter
 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)
コード例 #5
0
ファイル: page.py プロジェクト: pombredanne/py.saunter
    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
コード例 #6
0
ファイル: page.py プロジェクト: pombredanne/py.saunter
    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
コード例 #7
0
ファイル: number.py プロジェクト: LillianWang/py.saunter
 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)
コード例 #8
0
ファイル: page.py プロジェクト: pombredanne/py.saunter
    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
コード例 #9
0
ファイル: page.py プロジェクト: pombredanne/py.saunter
 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
コード例 #10
0
ファイル: number.py プロジェクト: Desperado/py.saunter
 def __set__(self, obj, val):
     e = SaunterWebDriver.find_element_by_locator(self.locator)
     e.send_keys(val)
コード例 #11
0
ファイル: shirts.py プロジェクト: pombredanne/py.saunter
 def get_meta_element(self, name):
     return SaunterWebDriver.find_element_by_locator('css=meta[name="%s"]' % name)
コード例 #12
0
ファイル: shirts.py プロジェクト: pombredanne/py.saunter
 def get_meta_elements(self):
     return SaunterWebDriver.find_elements_by_locator("tag=meta")
コード例 #13
0
ファイル: shirts.py プロジェクト: pombredanne/py.saunter
 def is_collar_selected(self, style):
     if SaunterWebDriver.is_element_present("%s .sl-deSel" % locators["collar style"].replace("REPLACE", style)):
         return False
     return True
コード例 #14
0
ファイル: shirts.py プロジェクト: pombredanne/py.saunter
 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)
コード例 #15
0
ファイル: number.py プロジェクト: LillianWang/py.saunter
 def __set__(self, obj, val):
     e = SaunterWebDriver.find_element_by_locator(self.locator)
     e.send_keys(val)