class LoggingTest(unittest.TestCase): def setUp(self): self._server = ChromeDriverLauncher( test_paths.CHROMEDRIVER_EXE).Launch() self._factory = ChromeDriverFactory(self._server) def tearDown(self): self._factory.QuitAll() self._server.Kill() def testNoVerboseLogging(self): driver = self._factory.GetNewDriver() url = self._factory.GetServer().GetUrl() driver.execute_script('console.log("HI")') req = SendRequest(url + '/log', method='GET') log = req.read() self.assertTrue(':INFO:' not in log, ':INFO: in log: ' + log) # crbug.com/94470 def DISABLED_testVerboseLogging(self): driver = self._factory.GetNewDriver({'chrome.verbose': True}) url = self._factory.GetServer().GetUrl() driver.execute_script('console.log("HI")') req = SendRequest(url + '/log', method='GET') log = req.read() self.assertTrue(':INFO:' in log, ':INFO: not in log: ' + log)
class ChromeDriverTest(unittest.TestCase): """Fixture for tests that need to instantiate ChromeDriver(s).""" @staticmethod def GlobalSetUp(other_driver=None, other_chrome=None): driver_path = other_driver or test_paths.CHROMEDRIVER_EXE chrome_path = other_chrome or test_paths.CHROME_EXE if driver_path is None or not os.path.exists(driver_path): raise RuntimeError('ChromeDriver could not be found') if chrome_path is None or not os.path.exists(chrome_path): raise RuntimeError('Chrome could not be found') ChromeDriverTest._driver_path = driver_path ChromeDriverTest._chrome_path = chrome_path ChromeDriverTest._server = ChromeDriverLauncher(driver_path).Launch() ChromeDriverTest._http_server = ChromeDriverLauncher( driver_path, test_paths.TEST_DATA_PATH).Launch() ChromeDriverTest._https_server = _HttpsServer( test_paths.PEM_CERT_AND_KEY, test_paths.TEST_DATA_PATH) @staticmethod def GlobalTearDown(): ChromeDriverTest._server.Kill() ChromeDriverTest._http_server.Kill() ChromeDriverTest._https_server.Shutdown() @staticmethod def GetTestDataUrl(): """Returns the base http url for serving files from the test dir.""" return ChromeDriverTest._http_server.GetUrl() @staticmethod def GetHttpsTestDataUrl(): """Returns the base https url for serving files from the test dir.""" return ChromeDriverTest._https_server.GetUrl() @staticmethod def GetDriverPath(): """Returns the path to the default ChromeDriver binary to use.""" return ChromeDriverTest._driver_path @staticmethod def GetChromePath(): """Returns the path to the default Chrome binary to use.""" return ChromeDriverTest._chrome_path def setUp(self): self._factory = ChromeDriverFactory(self._server, self.GetChromePath()) def tearDown(self): self._factory.QuitAll() def GetServer(self): """Returns the ChromeDriver server being used.""" return self._server def GetNewDriver(self, capabilities={}): """Returns a new RemoteDriver instance.""" self.assertTrue(self._factory, 'ChromeDriverTest.setUp must be called') return self._factory.GetNewDriver(capabilities)
class ChromeDriverTest(unittest.TestCase): """Fixture for tests that need to instantiate ChromeDriver(s).""" def setUp(self): self._factory = ChromeDriverFactory(test_environment.GetServer()) def tearDown(self): self._factory.QuitAll() def GetNewDriver(self, capabilities={}): """Returns a new RemoteDriver instance.""" self.assertTrue(self._factory, 'ChromeDriverTest.setUp must be called') return self._factory.GetNewDriver(capabilities)