Apr-07-2022, 05:28 AM
I am a bit confused about my migration problem. Some Selenium libraries have been deprecated but I cannot figure out how to make the appropriate changes. I apparently have to use 'Service' rather than 'Options' and 'executable_path'. My imports need to be different. Unfortunately reading the documentation I do not see how to specify the location of Firefox and geckodriver. Here is my relevant code segments that works under Windows 7:
from selenium import webdriver from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import TimeoutException from selenium.webdriver.firefox.firefox_binary import FirefoxBinaryThis is where I get errors (correction to line 2 I was able to figure out). Line 3 & 4 is where I get the deprecated error.
options=Options() options.add_argument("--headless") options.binary=FirefoxBinary(r'C:\Program Files\Mozilla Firefox\firefox.exe') browser=webdriver.Firefox(executable_path=r'C:Program Files\Mozilla Firefox\geckodriver.exe',options=options)Can someone help me convert this code for Windows 10? TIA