Created
July 26, 2011 19:24
-
-
Save santiycr/1107711 to your computer and use it in GitHub Desktop.
Ignoring open failures as letting call selenium commands right from self, reporting pass/fail status automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SeleniumTestCase(TestCase): | |
| # Let us just call self.click or self.type instead of self.selenium.type | |
| def __getattr__(self, name): | |
| if hasattr(self, 'selenium'): | |
| return getattr(self.selenium, name) | |
| raise AttributeError(name) | |
| # Ignore open commands that fail (same needs to be don for wait_for_page_to_load) | |
| def open(self, url, ignoreResponseCode=True): | |
| try: | |
| self.selenium.open(url, ignoreResponseCode) | |
| except Exception, e: | |
| print "Open failed on %s. Exception: %s" % (url, str(e)) | |
| pass #sometimes open appears to work fine but flakes out. ignore those | |
| # Report pass/fail status to Sauce Labs | |
| def tearDown(self): | |
| passed = {'passed': self._exc_info() == (None, None, None)} | |
| self.set_context("sauce: job-info=%s" % json.dumps(passed)) | |
| self.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment