Home > Software design >  Why do I get a deprecationWarning: Selenium Tools for Microsoft Edge is deprecated. Please upgrade t
Why do I get a deprecationWarning: Selenium Tools for Microsoft Edge is deprecated. Please upgrade t

Time:05-22

I have the following selenium code:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge
from selenium.webdriver.support import expected_conditions as EC
import os

options= EdgeOptions()
options.use_chromium=True
options.add_argument("headless")
options.add_argument("disable-gpu")

driver=Edge(executable_path=r'C:\Users\A\Desktop\Automated\msedgedriver.exe', options=options)

params={'behavior':'allow','downloadPath':os.getcwd()}
driver.execute_cdp_cmd('Page.setDownloadBehavior',params)

driver.get("https://www.ons.gov.uk/peoplepopulationandcommunity/healthandsocialcare/healthandwellbeing/datasets/worriesaboutreturntoschoolorcollege")

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "/html/body/main/div[3]/div/div[1]/section[2]/div/div[2]/div/div/a"))).click()

When I run the code, I get the following warning:

DeprecationWarning: Selenium Tools for Microsoft Edge is deprecated. Please upgrade to Selenium 4 which has built-in support for Microsoft Edge (Chromium): https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/#upgrading-from-selenium-3

How can I adjust the code so that the warning does not appear?

CodePudding user response:

The error tells you that you need to upgrade to the latest selenium because your current browser doesn't support selenium 4. So either you upgrade your selenium or downgrade to a older version of your browser.

CodePudding user response:

Replace

Edge(executable_path='...')

with

Edge(service=Service('...'))

and put this at the beginning of the script

from selenium.webdriver.chrome.service import Service
  • Related