def runTest(self, test_name): """Runs the test. Compares output from Chrome to the output in the log file. Args: test_name: name of the test to run from run_py_tests.py. """ log_file = os.path.join(ChromeDriverClientReplayTest.log_dir, test_name + ".log") GenerateTestLog(test_name, _CHROMEDRIVER, _CHROME, log_file) with open(log_file) as lf: replay_path = log_file if _OPTIONS.devtools_replay else "" server = client_replay.StartChromeDriverServer( _CHROMEDRIVER, _OPTIONS.output_log_path, replay_path) chrome_binary = (util.GetAbsolutePathOfUserPath(_CHROME) if _CHROME else None) replayer = client_replay.Replayer(lf, server, chrome_binary, self.server_url) real_response = None while True: command = replayer.command_sequence.NextCommand(real_response) if not command: break logged_response = replayer.command_sequence._last_response real_response = replayer.executor.Execute( client_replay._COMMANDS[command.name], command.GetPayloadPrimitive()) self.CheckResponsesMatch(real_response["value"], logged_response.GetPayloadPrimitive()) server.Kill()
def runTest(self, log_file_relative_path): """Runs the test. Args: log_file_relative_path: relative path (from this the directory this file is in) to the log file for this test as a string. """ log_file = os.path.join(_THIS_DIR, log_file_relative_path) with open(log_file) as lf: server = client_replay.StartChromeDriverServer( _CHROMEDRIVER, _OPTIONS) chrome_binary = (util.GetAbsolutePathOfUserPath(_OPTIONS.chrome) if _OPTIONS.chrome else None) replayer = client_replay.Replayer(lf, server, chrome_binary, self.server_url) real_response = None while True: command = replayer.command_sequence.NextCommand(real_response) logged_response = replayer.command_sequence._last_response if not command: break real_response = replayer.executor.Execute( client_replay._COMMANDS[command.name], command.GetPayloadPrimitive()) self.CheckResponsesMatch(real_response["value"], logged_response.GetPayloadPrimitive()) server.Kill()
def testRunMethod(self): """Check the Replayer.run method, which the other tests bypass.""" log_path = os.path.join(_THIS_DIR, "test_data/testGetTitle.log") with open(log_path) as lf: server = client_replay.StartChromeDriverServer( _CHROMEDRIVER, _OPTIONS) chrome_binary = (util.GetAbsolutePathOfUserPath(_OPTIONS.chrome) if _OPTIONS.chrome else None) client_replay.Replayer(lf, server, chrome_binary, self.server_url).Run() server.Kill()