0

Every time when i run my selenium script it shows some warnings. Can anyone explain me the reason of the warnings and how to solve it.

C:\Users\1154-Talha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py:418: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  if resp.getheader('Content-Type') is not None:
C:\Users\1154-Talha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py:419: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  content_type = resp.getheader('Content-Type').split(';')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

1

Selenium requires urllib3

urllib3

getheader() is deprecated now and will be removed in urllib3 v2.1.0. Instead with Selenium we need to use HTTPResponse.headers.get(name, default).


Details

This issue was discussed in the thread DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. and was addressed through pull request Replace response.getheader() with response.headers.get() which replaces response.getheader() with response.headers.get() deprecated in urllib3 1.26.13 which will prevent lots of deprecation warnings when using the selenium 4.6.1 and above.


Solution

Upgrade to Selenium 4.6.1 or above.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
-1

HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default)