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

fix: driver path check #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions webbot/webbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Browser:
- List containing all the errors which might have occurred during performing an action like click ,type etc.
"""

def __init__(self, showWindow=True, proxy=None , downloadPath:str=None, driverPath:str=None, arguments=["--disable-dev-shm-usage","--no-sandbox"]):
def __init__(self, showWindow=True, proxy=None , downloadPath:str=None, driverPath:str=None, arguments=["--disable-dev-shm-usage","--no-sandbox"], binaryLocation:str=None):
options = webdriver.ChromeOptions()

for argument in arguments:
Expand All @@ -53,9 +53,15 @@ def __init__(self, showWindow=True, proxy=None , downloadPath:str=None, driverPa

if driverPath is not None and isinstance(driverPath,str):
driverPath = os.path.abspath(driverPath)
if(not os.path.isdir(driverPath)):
if(not os.path.isfile(driverPath)):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), driverPath)

if binaryLocation is not None and isinstance(binaryLocation,str):
binaryLocation = os.path.abspath(binaryLocation)
if(not os.path.isfile(binaryLocation)):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), binaryLocation)
options.binary_location = binaryLocation

if proxy is not None and isinstance(proxy, str):
# Check if '--proxy-server' has not yet been set
if not any(arg.starts_with("--proxy-server") for arg in arguments):
Expand Down