Skip to content

Commit

Permalink
Disable some chrome features
Browse files Browse the repository at this point in the history
  • Loading branch information
owickstrom committed Nov 6, 2022
1 parent 0c653e4 commit 659e350
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions quickstrom/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def run_sessions() -> List[result.PlainResult]:
driver.get(self.origin)
for cookie in self.cookies:
self.log.debug(f"Setting {cookie}")
driver.add_cookie(dataclasses.asdict(cookie))
driver.add_cookie(
dataclasses.asdict(cookie))
# Now that cookies are set, we have to visit the origin again.
driver.get(self.origin)
# Hacky sleep to allow page load.
Expand All @@ -244,7 +245,8 @@ def run_sessions() -> List[result.PlainResult]:

scripts.install_event_listener(
driver, msg.dependencies)
await_events(driver, msg.dependencies, state_version, 10000)
await_events(driver, msg.dependencies,
state_version, 10000)

await_session_commands(driver, msg.dependencies,
state_version)
Expand Down Expand Up @@ -335,11 +337,15 @@ def new_driver(self):
options.headless = self.headless
browser_path = which("chrome") or which("chromium")
options.binary_location = browser_path # type: ignore
options.add_argument('--no-sandbox')
options.add_argument("--single-process")
options.add_argument("--disable-dev-shm-usage")
chromedriver_path = which('chromedriver')
if not chromedriver_path:
raise Exception("chromedriver not found in PATH")
return webdriver.Chrome(options=options,
executable_path=chromedriver_path)
executable_path=chromedriver_path,
service_log_path=self.driver_log_file)
elif self.browser == 'firefox':
options = firefox_options.Options()
options.headless = self.headless
Expand All @@ -351,7 +357,8 @@ def new_driver(self):
return webdriver.Firefox(options=options,
firefox_binary=binary,
executable_path=geckodriver_path,
service_log_path=self.driver_log_file or "geckodriver.log")
service_log_path=self.driver_log_file
or "geckodriver.log")
else:
raise Exception(f"Unsupported browser: {self.browser}")

Expand Down

0 comments on commit 659e350

Please sign in to comment.