nateshmbhat / webbot

Web automation library for simple and easy end to end testing and web browser automation that offers super charged features while keeping it simple to use and master
https://pypi.org/project/webbot/
Mozilla Public License 2.0
239 stars 87 forks source link

browser function #48

Open lobatim opened 3 years ago

lobatim commented 3 years ago

When I execute function browser() I get his error, someone can help me ?

Browser() Traceback (most recent call last): File "", line 1, in File "C:\Users\paulo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\webbot\webbot.py", line 58, in init self.driver = webdriver.Chrome(executable_path=driverpath , chrome_options=options) File "C:\Users\paulo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in init RemoteWebDriver.init( File "C:\Users\paulo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\Users\paulo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\paulo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\paulo\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.18363 x86_64)

issue-label-bot[bot] commented 3 years ago

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

BrieoRobino commented 3 years ago

Same problem. same errors.

LukeSavefrogs commented 3 years ago

Do you have Chrome installed?

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.18363 x86_64)

Pigii commented 3 years ago

i have the same exact problem. i hope i will find someone that can fix that issue

Guthman commented 3 years ago

How to fix:

open webbot.py with a text editor

Change

def __init__(self, showWindow=True, proxy=None , downloadPath:str=None):

into

def __init__(self, showWindow=True, proxy=None , downloadPath:str=None, executable_path:str=None):

then replace the block

        driverfilename = ''
        if sys.platform == 'linux' or sys.platform == 'linux2':
            driverfilename = 'chrome_linux'
        elif sys.platform == 'win32':
            driverfilename = 'chrome_windows.exe'
        elif sys.platform == 'darwin':
            driverfilename = 'chrome_mac'
        driverpath = os.path.join(os.path.split(__file__)[0], 'drivers{0}{1}'.format(os.path.sep, driverfilename))

with

        if executable_path:
            driverpath = executable_path
        else:
            driverfilename = ''
            if sys.platform == 'linux' or sys.platform == 'linux2':
                driverfilename = 'chrome_linux'
            elif sys.platform == 'win32':
                driverfilename = 'chrome_windows.exe'
            elif sys.platform == 'darwin':
                driverfilename = 'chrome_mac'
            driverpath = os.path.join(os.path.split(__file__)[0], 'drivers{0}{1}'.format(os.path.sep, driverfilename))

Now you can pass the location of your chromedriver binary in the call to Browser(), like:

web = Browser(executable_path=r'C:\Users\You\chromedriver.exe')

Use a raw string (r'') if you use backslashes in the path. Otherwise you can use a regular string.

Pigii commented 3 years ago

that seems to help but it causes another error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Users\pgame\AppData\Local\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)