45

I got this while running the selenium webdriver script in python I also set the path in System Environment and also tried downloading the webdriver that matches with my chrome version. And also letest version also. But I still get this error:

[8552:6856:1120/155118.770:ERROR:device_event_log_impl.cc(211)] [15:51:18.771] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[8552:6856:1120/155118.774:ERROR:device_event_log_impl.cc(211)] [15:51:18.774] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[8552:6856:1120/155118.821:ERROR:device_event_log_impl.cc(211)] [15:51:18.821] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)

I used this in my code :

driver = webdriver.Chrome(resource_path("C:\\webdriver\\chromedriver.exe"))  # to open the chromebrowser
driver.get("https://web.whatsapp.com")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
UMANG BARAIYA
  • 571
  • 1
  • 4
  • 9
  • 3
    @DebabjanB did you end up resolving this? i'm having the same issue. – ranni rabadi Nov 26 '20 at 07:50
  • See this https://stackoverflow.com/a/65134639/6875391 In Chrome I followed chrome://flags and enabled Enable new USB backend option, after that the log message disappeared – klapshin Feb 06 '21 at 00:58
  • 1
    @klapshin I also get this 'Failed to read...' message - on my C#-Selenium-VS Code 2019 project. I went to chrome://flags but there is no 'Enable new USB backend option,' or anything with USB. – Anne Bailly Oct 24 '21 at 20:10
  • @AnneBailly lately they've fixed it https://bugs.chromium.org/p/chromium/issues/detail?id=637404 So it might be our chromedriver version needed to be updated to latest, or alternatively rollback to previous Chrome+chromedriver version where they do have such an option. To check if this is really a USB issue unplug the USB device and see if error dissapear. – klapshin Oct 25 '21 at 12:52

12 Answers12

59

This is a chromedriver issue that they're still working the kinks out of. I'm not entirely sure what's causing it, but the technical details seem to be detailed in Debanjan's answer.

The general solution on the internet just seems to be "ignore it", but it sure clutters up the logs a lot.

I did find a way to get it to shut up though (as well as the "DevTools" warning that pops up a lot as well).

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)

You can add your other chromedriver options and switches onto that as well, in addition to pointing to your chromedriver executable if you wish.

Joseph238
  • 1,174
  • 1
  • 14
  • 22
Rue Lazzaro
  • 671
  • 5
  • 4
  • 5
    For anyone wondering what the `Options` should be, I found `options = webdriver.ChromeOptions()` to do the job. – Niko Föhr Jan 31 '21 at 17:00
  • You're right. Won't let me review the edit. Depends on how you have your chrome driver set up, but that'll work in most cases. Gj! – Rue Lazzaro Mar 19 '21 at 19:18
  • @RueLazzaro where within your code or framework did you put this options code block? I get this 'Failed to read...' message on my C#-Selenium-VS Code 2019 project. I put that code block in dfferent places in the class but get compile error. I am a beginner learner so I am probably doing something wrong. – Anne Bailly Oct 24 '21 at 19:40
  • @AnneBailly No worries! This all python. I'm not sure how I'd rig it up in C#. I'm sorry! I'm sure someone can help you out though. In python, you define this all before you actually launch the driver and do stuff (like launch a web page and click around on stuff). – Rue Lazzaro Oct 25 '21 at 23:16
  • This'll do it in C# var options = new ChromeOptions(); options.AddExcludedArguments(new List {"excludeSwitches", "enable-logging"}); var driver = new ChromeDriver(options); – Dan Marshall Jul 18 '22 at 04:16
16

This error message...

[14432:11656:1120/161059.539:ERROR:device_event_log_impl.cc(211)] [16:10:59.539] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)

...implies that the ChromeDriver raised an error while in trying to initiate/spawn a new Browsing Context i.e. Chrome Browser session.


Analysis

This error occurs due to an USB device which is attached to the system and isn't functioning properly.

This error is defined within usb_device_handle_win.cc as follows:

void UsbDeviceHandleWin::GotDescriptorFromNodeConnection(
    TransferCallback callback,
    scoped_refptr<base::RefCountedBytes> request_buffer,
    scoped_refptr<base::RefCountedBytes> original_buffer,
    Request* request_ptr,
    DWORD win32_result,
    size_t bytes_transferred) {
  std::unique_ptr<Request> request = UnlinkRequest(request_ptr);
  if (win32_result != ERROR_SUCCESS) {
    SetLastError(win32_result);
    USB_PLOG(ERROR) << "Failed to read descriptor from node connection";
    std::move(callback).Run(UsbTransferStatus::TRANSFER_ERROR, nullptr, 0);
    return;
  }

Solution

This error isn't harmful and doesn't blocks the spawning of the new Browsing Context i.e. Chrome Browser session. So you can safely ignore the error.

However in your code block you need to replace the keyword resource_path with executable_path and your effective code block will be:

webdriver.Chrome(executable_path=r'C:\webdriver\chromedriver.exe') # to open the chromebrowser 
driver.get("https://web.whatsapp.com")

References

You can find a couple of relevant detailed discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 2
    I didn't attach any USB devices. And I need to get rid off this error because I need to turn this script into a window ".exe" file to run on any window machine. – UMANG BARAIYA Nov 21 '20 at 06:49
  • @UMANGBARAIYA The error is from a callback from Chrome/ChromeDriver and doesn't effects your test and test results. Resulten `exe` file would also work perfecto. – undetected Selenium Nov 21 '20 at 20:45
  • This did not work for me. The driver does launch but I am entering commands through python prompt and when I was giving it the next command the error came in prompt. I fear that if i will make any script this error will not let the script work. – Vinamra Bali Jan 02 '21 at 02:09
10

After a week of finding an answer to my error, I ended up with a solution that you just need to install pywin32 library and it will not gives you an error

open cmd and type

pip install pywin32

and you are good to go.....!

UMANG BARAIYA
  • 571
  • 1
  • 4
  • 9
7

Solution:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time

options = Options()

options.add_experimental_option('excludeSwitches', ['enable-logging'])

driver = webdriver.Chrome(executable_path=r"D:\SW\chromedriver90\chromedriver.exe",chrome_options=options)

url = 'https://carlsagan.com/'

driver.get(url)

...

driver.quit()
Lucan
  • 2,907
  • 2
  • 16
  • 30
Dennis
  • 81
  • 1
  • 1
2

i found a fix!! first download this chrome extension then click the extension, and set the user-agent to "Chrome on Mac"

second change this line in your code

driver = webdriver.Chrome(resource_path("C:\\webdriver\\chromedriver.exe"))  # to open the chromebrowser
driver.get("https://web.whatsapp.com")

to:

driver = webdriver.Chrome(executable_path=r'C:\webdriver\chromedriver.exe')  # to open the chromebrowser
driver.get("https://web.whatsapp.com")

also open cmd and type:

pip install pywin32
tago
  • 21
  • 2
1

check your device list to see if there is any usb devices doesn't work. I solved this after My laptop have been enabled bluetooth and cam devices.enter image description here

J. Mar
  • 55
  • 1
  • 7
  • 1
    I did not attach any kind of USB device while running this code and the code does not need any kind of USB device to run this code I fully independent – UMANG BARAIYA Dec 22 '20 at 17:01
0

The error is probably because you have used parenthesis in the resource_path variable. The code should be as following:

driver = webdriver.Chrome(resource_path="C:\webdriver\chromedriver.exe") # to open the chromebrowser 
driver.get("https://web.whatsapp.com")

if still there is any problem you can try keeping the web driver in the same folder as the python file.

TG Himanshu
  • 78
  • 1
  • 9
0

The error

[15292:18896:0820/144926.111:ERROR:device_event_log_impl.cc(214)] [14:49:26.110] USB: usb_device_handle_win.cc:1048 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)

disappeared after downloading and using the required web driver version for my chrome version I have installed. See https://chromedriver.chromium.org/downloads

DaveX
  • 147
  • 1
  • 4
0

options.add_experimental_option("excludeSwitches", ["enable-logging"]) did the trick for me without having to install pywin32.

SatishKG
  • 85
  • 7
0
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_experimental_option("detach", True)

driver = webdriver.Chrome(options=chrome_options)

This worked for me, hope it helps someone.

fulo
  • 95
  • 1
  • 7
-1

I have tried many methods, but none has worked for me.

All I can do is delay the automatic exit of the Chrome browser with time modue.

from selenium import webdriver
import chromedriver_binary  # Adds chromedriver binary to path
import time

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
driver = webdriver.Chrome(options=options)

driver.get('https://www.google.com/')
time.sleep(3600) # let the browser die after 1 hour
D.Cosmos
  • 1
  • 2
-2

Please check the spec file name once . I have renamed the spec file but forget to update it in config file so getting this error . Later I changed . It solved