Unable to execute sample code "Transition to specified url"

Asked 2 years ago, Updated 2 years ago, 125 views

I'm a Python beginner.
Sample code for transition to specified url

I looked it up on the Internet.
 from selenium import webdriver
driver=webdriver.Chrome("C:/Desktop/chromedriver.exe")
driver.get ("https://www.yahoo.co.jp/")

When I ran with IDLE, I saw the following:

Traceback (most recent call last):
  File "C:\Users\kenny\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process=subprocess.Popen(cmd, env=self.env,
  File "C:\Users\kenny\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\kenny\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in_execute_child
    hp,ht,pid,tid=_winapi.CreateProcess(executable,args,
FileNotFoundError: [WinError2] The specified file cannot be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/kenny/Desktop/test.py", line 2, in <module>
    driver=webdriver.Chrome("C:/Desktop/chromedriver.exe")
  File "C:\Users\kenny\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in__init__
    self.service.start()
  File "C:\Users\kenny\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line81, in start
    raise WebDriverException(
selenium.common.exception.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH.Please see https://sites.google.com/a/chromium.org/chromedriver/home

Also, after rewriting the code below,

 from selenium import webdriver
driver = webdriver.Chrome
driver.get ("https://www.yahoo.co.jp/")

This time, the following is displayed:

Traceback (most recent call last):
  File "C:/Users/kenny/Desktop/test.py", line 3, in <module>
    driver.get ("https://www.yahoo.co.jp/")
TypeError: get() missing 1 required positional argument: 'url'

selenium and Chromedriver are already installed.
I tried many things, but I couldn't make it, so I asked you a question.
I am a complete beginner, but I appreciate your cooperation.

python windows selenium chromedriver

2022-09-29 22:39

1 Answers

The direct cause may be driver=webdriver.Chrome without () after it.
Try the following:

 from selenium import webdriver
driver=webdriver.Chrome()
driver.get ("https://www.yahoo.co.jp/")

However, there seems to be another problem that may be affected by the number of Chrome or ChromeDriver editions.
The number of Chrome editions is 88.0.4324.150
ChromeDriver has 88.0.4324.96

This error appears.

>>[4940:10520:0215/120439.701:ERROR:device_event_log_impl.cc(211)][12:04:39.702]USB:usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: The device connected to the system is not functioning (0xF)

I changed the number of versions of ChromeDriver to 88.0.4324.27 which is one older version.
There is a high possibility that it is a Chrome problem, but it is difficult to deal with without having an older version of the installer.
Downgrade the Chrome version (Windows)

It seems that even if the above error occurs, the processing can continue.

@kenny I'm not sure if the error will occur in 2021jp's environment, but if so, would you like to ignore the error and continue using it, or use FireFox and geckodriver as a reference to this article until it is fixed?
Try headless Firefox on Windows 10+Python3+selenium+geckodriver
By the way, the current geckodriver's latest version is 0.29.0.

According to this article, it originated from Chrome v87 and fixed with Chrome v90.
USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection error with ChromeDriver v87/Chrome v87 using Selenium on Windows 10

The comment says that when you enable Enable new USB backend in chrome://flags, the message disappears, but the error message still appears (maybe Chrome himself had to be in the canary version, but he didn't).

There is an article like this in Japanese.It seems to be working even if you ignore it.
Error automating login in selenium [ERROR:device_event_log_impl.cc(211)]
[Python novice]Automatically log in from Amazon login page using Chrome on Python and Selenium
Get Web Page Title in Python using Selenium


2022-09-29 22:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.