问题1:添加了环境变量后仍然Expected browser binary location, but unable to find binary in default location, no ‘moz:firefoxOptions.binary’ capability provided, and no binary flag set on the command line
问题2:照着stackoverflow上的方法解决了问题1后DeprecationWarning: executable_path has been deprecated, please pass in a Service object
// 完美运行
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
s=Service(r'C:\Python39\geckodriver.exe')//geckodriver.exe在github下载
options = Options()
options.binary_location =r'C:\Program Files\Mozilla Firefox\firefox.exe'//firefox的地址
driver = webdriver.Firefox(service=s, options=options)
driver.get('https://xenoblade2.cn')print(driver.title)
driver.quit()