Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support undetected-chromedriver #1110

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions splinter/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

_DRIVERS: Dict[str, Union[None, Type[DriverAPI]]] = {
'chrome': None,
'undetected_chrome': None,
'edge': None,
'firefox': None,
'remote': None,
Expand All @@ -38,10 +39,12 @@

try:
from splinter.driver.webdriver.chrome import WebDriver as ChromeWebDriver
from splinter.driver.webdriver.undetected_chrome import WebDriver as undetected_ChromeWebDriver
from splinter.driver.webdriver.firefox import WebDriver as FirefoxWebDriver
from splinter.driver.webdriver.remote import WebDriver as RemoteWebDriver

_DRIVERS['chrome'] = ChromeWebDriver
_DRIVERS['undetected_chrome'] = undetected_ChromeWebDriver
_DRIVERS['firefox'] = FirefoxWebDriver
_DRIVERS['remote'] = RemoteWebDriver
except ImportError as e:
Expand Down
43 changes: 43 additions & 0 deletions splinter/driver/webdriver/undetected_chrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-

# Copyright 2012 splinter authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

import undetected_chromedriver as uc
from splinter.driver.webdriver import BaseWebDriver


class WebDriver(BaseWebDriver):

driver_name = "undetected_Chrome"

def __init__(
self,
options=None,
user_agent=None,
wait_time=2,
fullscreen=False,
incognito=False,
headless=False,
**kwargs
):

options = uc.ChromeOptions()

if user_agent is not None:
options.add_argument("--user-agent=" + user_agent)

if incognito:
options.add_argument("--incognito")

if fullscreen:
options.add_argument("--kiosk")

if headless:
options.add_argument("--headless")
options.add_argument("--disable-gpu")

driver = uc.Chrome(options=options, **kwargs)

super(WebDriver, self).__init__(driver, wait_time)