Пример #1
0
 def test_saving(self):
     manager_params, browser_params = self.get_config()
     manager = TaskManager(manager_params, browser_params)
     manager.get("http://example.com")
     manager.close()
     assert isfile(
         join(browser_params[0].profile_archive_dir, "profile.tar.gz"))
Пример #2
0
 def test_crash(self):
     manager_params, browser_params = self.get_config()
     manager_params.failure_limit = 0
     manager = TaskManager(manager_params, browser_params)
     with pytest.raises(CommandExecutionError):
         manager.get("http://example.com")  # So we have a profile
         manager.get("example.com")  # Selenium requires scheme prefix
         manager.get("example.com")  # Requires two commands to shut down
Пример #3
0
 def test_crash_profile(self):
     manager_params, browser_params = self.get_config()
     manager_params.failure_limit = 2
     manager = TaskManager(manager_params, browser_params)
     try:
         manager.get("http://example.com")  # So we have a profile
         manager.get("example.com")  # Selenium requires scheme prefix
         manager.get("example.com")  # Selenium requires scheme prefix
         manager.get("example.com")  # Selenium requires scheme prefix
         manager.get("example.com")  # Requires two commands to shut down
     except CommandExecutionError:
         pass
     assert isfile(join(browser_params[0].profile_archive_dir, "profile.tar.gz"))
Пример #4
0
    def test_profile_saved_when_launch_crashes(self):
        manager_params, browser_params = self.get_config()
        browser_params[0].proxy = True
        browser_params[0].save_content = "script"
        manager = TaskManager(manager_params, browser_params)
        manager.get("http://example.com")

        # Kill the LevelDBAggregator
        # This will cause the proxy launch to crash
        manager.ldb_status_queue.put("DIE")
        manager.browsers[0]._SPAWN_TIMEOUT = 2  # Have timeout occur quickly
        manager.browsers[0]._UNSUCCESSFUL_SPAWN_LIMIT = 2  # Quick timeout
        manager.get("example.com")  # Cause a selenium crash

        # The browser will fail to launch due to the proxy crashes
        try:
            manager.get("http://example.com")
        except CommandExecutionError:
            pass
        manager.close()
        assert isfile(join(browser_params[0].profile_archive_dir, "profile.tar.gz"))