Пример #1
0
    def check(self, schedule, data):
        start = time.time()
        start_time = datetime.now()
        result = False

        source = data["selenium_source"]["source"].encode("utf-8")
        screenshot = "/tmp/selenium_screenshot-%d.png" % schedule.schedule_id

        # Skipping screenshot for now
        '''if not 'captureEntirePageScreenshot' in source:                
            index = source.find("</tbody>")
            if index == -1: index = source.find("</table>")
            if index != -1:
                new_row = """<tr>
                                <td>captureEntirePageScreenshot</td>
                                <td>%s</td>
                                <td></td>
                             </tr>""" %  screenshot
                source = source[:index] + new_row + source[index:]'''

        sourceobj = StringIO.StringIO()
        sourceobj.write(source)
        sourceobj.seek(0)

        try:
            test = TestRunner.from_file(sourceobj)
            try:
                test_result = test.run(webdriver.PhantomJS(service_log_path="/var/log/checker/ghostdriver.log"))
                # Skipping screenshot for now
                # test_result.copy_files(screenshot)
                result = 1
            except:
                result = 0
        except:
            if data["selenium_source"].has_key("code_b64"):
                code = base64.b64decode(data["selenium_source"]["code_b64"])
            else:
                code = data["selenium_source"]["code"]

            exec(code)

            sel = selenium(
                self.config.get("Selenium", "host"),
                self.config.get("Selenium", "port"),
                "*chrome",
                locals()["base_url"],
            )
            SeleniumTest = locals()["SeleniumTest"]
            SeleniumTest.selenium = sel
            sel.start()

            test_result = unittest.TestResult()
            test = SeleniumTest()
            # Skipping screenshot for now
            # test.screenshot_file = screenshot
            test.run(test_result)
            result = test_result.wasSuccessful()

        duration = time.time() - start
        return start_time, result, duration
Пример #2
0
 def start_test(self, url="http://localhost"):
     self.selenium = selenium(self.__host__, self.__port__, self.__browser__, url)
     try:
         self.selenium.start()
     except Exception, e:
         sys.stderr.write("Error when starting selenium. Is it running ? Error: %s\n" % unicode(e))
         sys.exit(1)
Пример #3
0
    def start_selenium(self, url):
        host = extasy.settings.get( "selenium-server", "localhost" )
        port = int( extasy.settings.get( "selenium-port", 4444 ) )
        browser_to_run = extasy.settings.get( 'browser' )
        
        if not self.selenium:
            if not browser_to_run.startswith("*"):
                browser_to_run = "*%s" % browser_to_run
            self.selenium = selenium(host, port, browser_to_run, url)

        try:
            self.selenium.start()
        except Exception, e:
            raise DriverError("Error when starting selenium. Is it running?\n\n\n Error: %s\n" % format_exc(e))
Пример #4
0
    def start_selenium(self, url):
        host = self.context.settings.extra_args.get("selenium.server", "localhost")
        port = self.context.settings.extra_args.get("selenium.port", 4444)
        browser_to_run = self.context.settings.browser_to_run

        if not self.selenium:
            if not browser_to_run.startswith("*"):
                browser_to_run = "*%s" % browser_to_run
            self.selenium = selenium(host, port, browser_to_run, url)

        try:
            self.selenium.start()
        except Exception, e:
            raise DriverError("Error when starting selenium. Is it running?\n\n\n Error: %s\n" % format_exc(e))
    def start_test(self, url=None):
        host = self.context.settings.extra_args.get("selenium.server", "localhost")
        port = self.context.settings.extra_args.get("selenium.port", 4444)
        browser_to_run = self.context.settings.browser_to_run

        if not self.selenium:
            if not browser_to_run.startswith("*"):
                browser_to_run = "*%s" % browser_to_run
            self.selenium = selenium(host, port, browser_to_run, url)

        try:
            self.selenium.start()
        except Exception, e:
            raise DriverError("Error when starting selenium. Is it running?\n\n\n Error: %s\n" % format_exc(e))
Пример #6
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444,
                              "C:\Python27\Scripts\chromedriver.exe",
                              "http://wickedride.com/")
     self.selenium.start()
Пример #7
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("http://www.google.com/")
     self.selenium.start()
Пример #8
0
	def __init__(self, **kwargs):
		self.sel = selenium("localhost", 4444, "PhantomJS","/home/guowei/bin/phantomjs/bin/phantomjs")
		self.sel.start()
Пример #9
0
 def setUp(self):
     self.verificationErrors = []
     self.selenium = selenium("localhost", 4444, "*firefox", "https://www.google.com/")
     self.selenium.start()
Пример #10
0
 def setUp(self):
     """setUp"""
     self.sel = selenium("localhost", 4444, "*chrome", "http://google.com")
     self.sel.start()
Пример #11
0
 def setUp(self):
     """setUp"""
     self.sel = selenium("localhost", 4444, "*chrome",
                         "http://" + self.log_url)
     self.sel.start()