From 83b235f16fda5a7d9ae52e6b44c511b522abffac Mon Sep 17 00:00:00 2001 From: englehardt Date: Fri, 8 Apr 2016 13:29:57 -0400 Subject: [PATCH] Bugfix: supporting sleep after get in browse command --- automation/Commands/browser_commands.py | 7 ++++--- automation/Commands/command_executor.py | 6 +++--- automation/TaskManager.py | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/automation/Commands/browser_commands.py b/automation/Commands/browser_commands.py index 57661b6a8..9596ba03e 100644 --- a/automation/Commands/browser_commands.py +++ b/automation/Commands/browser_commands.py @@ -141,7 +141,8 @@ def extract_links(webdriver, browser_params, manager_params): sock.close() -def browse_website(url, num_links, webdriver, proxy_queue, browser_params, manager_params, extension_socket): +def browse_website(url, num_links, sleep, webdriver, proxy_queue, + browser_params, manager_params, extension_socket): """ calls get_website before visiting present on the page NOTE: top_url will NOT be properly labeled for requests to subpages @@ -149,7 +150,7 @@ def browse_website(url, num_links, webdriver, proxy_queue, browser_params, manag to this function. """ # First get the site - get_website(url, webdriver, proxy_queue, browser_params, extension_socket) + get_website(url, sleep, webdriver, proxy_queue, browser_params, extension_socket) # Connect to logger logger = loggingclient(*manager_params['logger_address']) @@ -166,7 +167,7 @@ def browse_website(url, num_links, webdriver, proxy_queue, browser_params, manag try: links[r].click() wait_until_loaded(webdriver, 300) - time.sleep(1) + time.sleep(max(1,sleep)) if browser_params['bot_mitigation']: bot_mitigation(webdriver) webdriver.back() diff --git a/automation/Commands/command_executor.py b/automation/Commands/command_executor.py index 9fef71058..328373c71 100644 --- a/automation/Commands/command_executor.py +++ b/automation/Commands/command_executor.py @@ -13,9 +13,9 @@ def execute_command(command, webdriver, proxy_queue, browser_settings, browser_p proxy_queue, browser_params, extension_socket) if command[0] == 'BROWSE': - browser_commands.browse_website(command[1], command[2], webdriver, - proxy_queue, browser_params, manager_params, - extension_socket) + browser_commands.browse_website(command[1], command[2], command[3], + webdriver, proxy_queue, browser_params, + manager_params, extension_socket) if command[0] == 'DUMP_FLASH_COOKIES': browser_commands.dump_flash_cookies(command[1], command[2], webdriver, diff --git a/automation/TaskManager.py b/automation/TaskManager.py index 24b9d051d..8c6c5cc1d 100644 --- a/automation/TaskManager.py +++ b/automation/TaskManager.py @@ -448,9 +448,9 @@ def get(self, url, sleep=0, index=None, timeout=60, reset=False): """ goes to a url """ self._distribute_command(('GET', url, sleep), index, timeout, reset) - def browse(self, url, num_links = 2, index=None, timeout=60, reset=False): + def browse(self, url, num_links=2, sleep=0, index=None, timeout=60, reset=False): """ browse a website and visit links on the page """ - self._distribute_command(('BROWSE', url, num_links), index, timeout, reset) + self._distribute_command(('BROWSE', url, num_links, sleep), index, timeout, reset) def dump_flash_cookies(self, url, start_time, index=None, timeout=60): """ dumps all Flash LSOs to db """