Home > Enterprise >  Unable to open a Website using Selenium on Pycharm
Unable to open a Website using Selenium on Pycharm

Time:10-27

I'm getting multiple error messages for which I tried googling but that did not work. I've added the Chrome driver in the same directory and tried to code but get a bunch of errors.

What am I doing wrong here?

Code :

from selenium import webdriver
driver = webdriver.Chrome()
driver.get('www.google.com')

Errors :

Traceback (most recent call last):
  File "C:\Users\Rajesh.Rao\PycharmProjects\Kofax\salesforce_login.py", line 3, in <module>
    driver.get('www.google.com')
  File "C:\Users\Rajesh.Rao\PycharmProjects\Kofax\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Users\Rajesh.Rao\PycharmProjects\Kofax\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 418, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Rajesh.Rao\PycharmProjects\Kofax\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
  (Session info: chrome=95.0.4638.54)
Stacktrace:
Backtrace:
    Ordinal0 [0x00BC3AB3 2505395]
    Ordinal0 [0x00B5AE41 2076225]
    Ordinal0 [0x00A62360 1057632]
    Ordinal0 [0x00A550C0 1003712]
    Ordinal0 [0x00A53F39 999225]
    Ordinal0 [0x00A54016 999446]
    Ordinal0 [0x00A63A6A 1063530]
    Ordinal0 [0x00AB56ED 1398509]
    Ordinal0 [0x00AA59F3 1333747]
    Ordinal0 [0x00AB5168 1397096]
    Ordinal0 [0x00AA58BB 1333435]
    Ordinal0 [0x00A823E4 1188836]
    Ordinal0 [0x00A8323F 1192511]
    GetHandleVerifier [0x00D4CB36 1554566]
    GetHandleVerifier [0x00DF4A0C 2242396]
    GetHandleVerifier [0x00C50E0B 523099]
    GetHandleVerifier [0x00C4FEB0 519168]
    Ordinal0 [0x00B602FD 2097917]
    Ordinal0 [0x00B64388 2114440]
    Ordinal0 [0x00B644C2 2114754]
    Ordinal0 [0x00B6E041 2154561]
    BaseThreadInitThunk [0x764CFA29 25]
    RtlGetAppContainerNamedObjectPath [0x77C87A9E 286]
    RtlGetAppContainerNamedObjectPath [0x77C87A6E 238]

CodePudding user response:

In case you are looking for auto-upgrade, Please use chromedriver-autoinstaller.

Automatically download and install chromedriver that supports the currently installed version of chrome. This installer supports Linux, MacOS and Windows operating systems.

Installation

pip install chromedriver-autoinstaller

Usage

Just type import chromedriver_autoinstaller in the module you want to use chromedriver.

Example

from selenium import webdriver
import chromedriver_autoinstaller


chromedriver_autoinstaller.install()  # Check if the current version of chromedriver exists
                                      # and if it doesn't exist, download it automatically,
                                      # then add chromedriver to path

driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title
  • Related