def testCorrectlyDisplaysSuccessStateForSingleBrowser(self): flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.token.username, client_id=self.client_id, flow_args=flow_args) with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.SUCCESS, num_collected_files=1, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Expand the flow. self.Click("css=.flow-title:contains('Browser History')") self.WaitUntil( self.IsElementPresent, "css=.row:contains('Chrome') .success:contains('1 file collected')" ) # Check that other browsers are not shown. self.WaitUntilNot(self.IsElementPresent, "css=.row:contains('Opera')") self.WaitUntilNot(self.IsElementPresent, "css=.row:contains('Safari')") self.WaitUntilNot(self.IsElementPresent, "css=.row:contains('Internet Explorer')") self.WaitUntilNot(self.IsElementPresent, "css=.row:contains('Firefox')")
def testDisplaysAndHidesResultsForSingleBrowser(self): flow_args = webhistory.CollectBrowserHistoryArgs(browsers=[ webhistory.CollectBrowserHistoryArgs.Browser.CHROME, webhistory.CollectBrowserHistoryArgs.Browser.OPERA, ]) flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.test_username, client_id=self.client_id, flow_args=flow_args) flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.CHROME, 0)], tag="CHROME") flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.OPERA, 0)], tag="OPERA") with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.SUCCESS, num_collected_files=1, ), webhistory.BrowserProgress( browser=webhistory.Browser.OPERA, status=webhistory.BrowserProgress.Status.SUCCESS, num_collected_files=1, ) ])): self.Open(f"/v2/clients/{self.client_id}") self.Click("css=.flow-title:contains('Browser History')") self.ScrollIntoView("css=div.title:contains('Chrome')") self.Click("css=div.title:contains('Chrome')") self.WaitUntil(self.IsElementPresent, "css=.results tr:contains('/home/foo/chrome-0')") # Only Chrome's results should be shown. self.WaitUntilNot(self.IsElementPresent, "css=.results tr:contains('/home/foo/opera-0')") # Second click should toggle the browser results view. self.Click("css=div.title:contains('Chrome')") self.WaitUntilNot( self.IsElementPresent, "css=.results tr:contains('/home/foo/chrome-0')") self.Click("css=div.title:contains('Opera')") self.WaitUntil(self.IsElementPresent, "css=.results tr:contains('/home/foo/opera-0')") # Only Opera's results should be shown. self.WaitUntilNot( self.IsElementPresent, "css=.results tr:contains('/home/foo/chrome-0')") # Second click should toggle the browser results view. self.Click("css=div.title:contains('Opera')") self.WaitUntilNot(self.IsElementPresent, "css=.results tr:contains('/home/foo/opera-9')")
def testUpdatesResultsOfRunningFlowDynamically(self): flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_id = flow_test_lib.StartFlow( webhistory.CollectBrowserHistory, creator=self.token.username, client_id=self.client_id, flow_args=flow_args) self.Open(f"/v2/clients/{self.client_id}") self.Click("css=.flow-title:contains('Browser History')") progress_0_results = webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=0, ) ]) with flow_test_lib.FlowProgressOverride(webhistory.CollectBrowserHistory, progress_0_results): self.WaitUntil(self.IsElementPresent, "css=div.title:contains('Chrome')") self.WaitUntilNot(self.IsElementPresent, "css=.header:contains('arrow_right')") flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.CHROME, i) for i in range(10)], tag="CHROME") progress_10_results = webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=10, ) ]) with flow_test_lib.FlowProgressOverride(webhistory.CollectBrowserHistory, progress_10_results): self.WaitUntil(self.IsElementPresent, "css=.header:contains('arrow_right')") self.Click("css=div.title:contains('Chrome')") self.WaitUntilEqual(10, self.GetCssCount, "css=tr:contains('/home/foo')") flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.CHROME, 11)], tag="CHROME") progress_11_results = webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=11, ) ]) with flow_test_lib.FlowProgressOverride(webhistory.CollectBrowserHistory, progress_11_results): self.WaitUntilEqual(11, self.GetCssCount, "css=tr:contains('/home/foo')")
def testDisplaysMultipleResultsForSingleBrowser(self): flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.test_username, client_id=self.client_id, flow_args=flow_args) flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.CHROME, i) for i in range(200)], tag="CHROME") with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.SUCCESS, num_collected_files=200, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Expand the flow. self.Click("css=.flow-title:contains('Browser History')") # Expand the browser. self.Click("css=div.title:contains('Chrome')") # Update pagination to display all the results. self.MatSelect("css=.top-paginator mat-select", "100") # Check that only first 100 results are visible. First row is the table # header, so we start with 1. self.WaitUntil(self.IsElementPresent, "css=.results tr:nth(1)") self.WaitUntilNot( self.IsElementPresent, "css=.results tr:nth(101):contains('/home/foo/chrome-99')") # Check that clicking Load More loads the rest. The button can be hidden # under the approval bottom sheet, so for now we workaround by clicking it # programmatically and not with a mouse event. self.WaitUntil(self.IsElementPresent, "css=button:contains('Load More')") self.driver.execute_script( """$("button:contains('Load More')").click();""") # Update pagination to display all the results. self.MatSelect("css=.top-paginator mat-select", "500") self.WaitUntil( self.IsElementPresent, "css=.results tr:nth(200):contains('/home/foo/chrome-199')") self.WaitUntilNot(self.IsElementPresent, "css=.results tr:nth(201)") # Check that the "load more" button disappears when everything is loaded. self.WaitUntilNot(self.IsElementPresent, "css=button:contains('Load More')")
def _RunCollectBrowserHistory(self, **kwargs): flow_args = webhistory.CollectBrowserHistoryArgs(**kwargs) flow_id = flow_test_lib.StartAndRunFlow( webhistory.CollectBrowserHistory, creator=self.token.username, client_mock=action_mocks.ActionMock(), client_id=self.client_id, flow_args=flow_args) results = flow_test_lib.GetFlowResults(self.client_id, flow_id) progress = flow_test_lib.GetFlowProgress(self.client_id, flow_id) return flow_id, results, progress
def testShowsDownloadButtonOnFlowCompletion(self): flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.test_username, client_id=self.client_id, flow_args=flow_args) with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=0, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Make sure that the flow panel is already displayed... self.WaitUntil(self.IsElementPresent, "css=.flow-title:contains('Browser History')") # ...and then check for the presence of the 'Download all' button. self.WaitUntilNot( self.IsElementPresent, "css=a[mat-stroked-button]:contains('Download all')") flow_test_lib.MarkFlowAsFinished(self.client_id, flow_id) with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=1, ), ])): with flow_test_lib.FlowResultMetadataOverride( webhistory.CollectBrowserHistory, rdf_flow_objects.FlowResultMetadata( is_metadata_set=True, num_results_per_type_tag=[ rdf_flow_objects.FlowResultCount( type=webhistory.CollectBrowserHistoryResult. __name__, count=1) ])): # The flow details view should get updated automatically. self.WaitUntil( self.IsElementPresent, "css=a[mat-stroked-button]:contains('Download')")
def testDisplaysMultipleResultsForSingleBrowser(self): flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.token.username, client_id=self.client_id, flow_args=flow_args) flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.CHROME, i) for i in range(200)], tag="CHROME") with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.SUCCESS, num_collected_files=200, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Expand the flow. self.Click("css=.flow-title:contains('Browser History')") # Expand the browser. self.Click("css=div.title:contains('Chrome')") # Check that only first 100 results are visible. First row is the table # header, so we start with 1. self.WaitUntil(self.IsElementPresent, "css=.results tr:nth(1)") self.WaitUntilNot( self.IsElementPresent, "css=.results tr:nth(101):contains('/home/foo/chrome-100')") # Check that clicking Load More loads the rest. self.Click("css=button:contains('Load More')") self.WaitUntil( self.IsElementPresent, "css=.results tr:nth(200):contains('/home/foo/chrome-199')") self.WaitUntilNot(self.IsElementPresent, "css=.results tr:nth(201)") # Check that the "load more" button disappears when everything is loaded. self.WaitUntilNot(self.IsElementPresent, "css=button:contains('Load more')")
def testAllowsCopyingResultPathToClipboard(self): # TODO: remove the skip instruction as soon as latest Chrome # and WebDriver versions are used in the CI infrastructure. self.skipTest("Temporarily disabling: running this test requires " "having latest Chrome/WebDriver versions in the CI " "setup.") flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.test_username, client_id=self.client_id, flow_args=flow_args) flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.CHROME, 0)], tag="CHROME") with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.SUCCESS, num_collected_files=1, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Expand the flow. self.Click("css=.flow-title:contains('Browser History')") # Expand the browser. self.Click("css=div.title:contains('Chrome')") # Hover and click on the copy button. self.MoveMouseTo( "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path" ) # Click on the now visible button. self.Click( "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path " "button.copy-button") clip_value = self.GetClipboard() self.assertEqual(clip_value, "/home/foo/chrome-0")
def testCorrectlyDisplaysInProgressStateForMultipleBrowsers(self): # Start the flow with 2 browsers scheduled for collection. flow_args = webhistory.CollectBrowserHistoryArgs(browsers=[ webhistory.CollectBrowserHistoryArgs.Browser.CHROME, webhistory.CollectBrowserHistoryArgs.Browser.OPERA, ]) flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.token.username, client_id=self.client_id, flow_args=flow_args) with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=0, ), webhistory.BrowserProgress( browser=webhistory.Browser.OPERA, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=0, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Expand the flow. self.Click("css=.flow-title:contains('Browser History')") self.WaitUntil(self.IsElementPresent, "css=.row:contains('Chrome') .in-progress") self.WaitUntil(self.IsElementPresent, "css=.row:contains('Opera') .in-progress") # Check that other browsers are not shown. self.WaitUntilNot(self.IsElementPresent, "css=.row:contains('Safari')") self.WaitUntilNot(self.IsElementPresent, "css=.row:contains('Internet Explorer')") self.WaitUntilNot(self.IsElementPresent, "css=.row:contains('Firefox')")
def testShowsDownloadButtonOnFlowCompletion(self): flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.token.username, client_id=self.client_id, flow_args=flow_args) with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=0, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Make sure that the flow panel is already displayed... self.WaitUntil(self.IsElementPresent, "css=.flow-title:contains('Browser History')") # ...and then check for the presence of the 'Download all' button. self.WaitUntilNot(self.IsElementPresent, "css=button:contains('Download all')") flow_test_lib.MarkFlowAsFinished(self.client_id, flow_id) with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.IN_PROGRESS, num_collected_files=1, ), ])): # The flow details view should get updated automatically. self.WaitUntil(self.IsElementPresent, "css=button:contains('Download all')")
def testAllowsCopyingResultPathToClipboard(self): flow_args = webhistory.CollectBrowserHistoryArgs( browsers=[webhistory.CollectBrowserHistoryArgs.Browser.CHROME]) flow_id = flow_test_lib.StartFlow(webhistory.CollectBrowserHistory, creator=self.token.username, client_id=self.client_id, flow_args=flow_args) flow_test_lib.AddResultsToFlow( self.client_id, flow_id, [_GenResults(webhistory.Browser.CHROME, 0)], tag="CHROME") with flow_test_lib.FlowProgressOverride( webhistory.CollectBrowserHistory, webhistory.CollectBrowserHistoryProgress(browsers=[ webhistory.BrowserProgress( browser=webhistory.Browser.CHROME, status=webhistory.BrowserProgress.Status.SUCCESS, num_collected_files=1, ), ])): self.Open(f"/v2/clients/{self.client_id}") # Expand the flow. self.Click("css=.flow-title:contains('Browser History')") # Expand the browser. self.Click("css=div.title:contains('Chrome')") # Hover and click on the copy button. self.MoveMouseTo( "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path" ) # Click on the now visible button. self.Click( "css=.results tr:nth(1):contains('/home/foo/chrome-0') td.path " "button.copy-button") clip_value = self.GetClipboard() self.assertEqual(clip_value, "/home/foo/chrome-0")