DeprecationWarning: use options instead of firefox_options,在firefox里面添加option警告

class MemberManage:
    def __init__(self):
        options=webdriver.FirefoxOptions()
        options.debugger_address="127.0.0.1:9922"
        self.driver=webdriver.Firefox(firefox_options=options)
        self.driver.implicitly_wait(5)
        self.driver.get("https://work.weixin.qq.com/wework_admin/frame")

有时候网站需要扫码登录,使用Selenium启动的浏览器进程可能没法完成登录,需要手动扫码登录后用Selenium进行操作。
步骤:
命令行执行:firefox.exe --remote-debugging-port=9222
1、打算在原有的页面上进行后续操作,添加了option.
添加之后运行报了上述警告:
DeprecationWarning: use options instead of firefox_options

查看源码其实是支持的:
class WebDriver(RemoteWebDriver):

class WebDriver(RemoteWebDriver):
    def __init__(self, firefox_profile=None, firefox_binary=None,
                 timeout=30, capabilities=None, proxy=None,
                 executable_path="geckodriver", options=None,
                 service_log_path="geckodriver.log", *firefox_options=None,*
                 service_args=None, desired_capabilities=None, log_path=None,
                 keep_alive=True):
       if firefox_options:
       			warnings.warn('use options instead of firefox_options', DeprecationWarning, stacklevel=2)
               options = firefox_options

查看源码只要带了firefox_options就会报这个警告,然后把值赋给options,所以可直接把这个值赋给options即不会报警告。
---------查看这个源码python版本3.8和3.7都是如此,因为之前安装的2.7已经卸载了,就没看了。
之前报错的时候,查看网上大家的说法就是3.8以上会存在这个问题,如果大家出现这个问题看下webdriver的源码如果如上则直接换为option即可.
谷歌的源码也有这个判断:

if chrome_options:
    warnings.warn('use options instead of chrome_options',
                  DeprecationWarning, stacklevel=2)
    options = chrome_options

Ie也有这一部分的判断:

if ie_options:
    warnings.warn('use options instead of ie_options',
                  DeprecationWarning, stacklevel=2)
    options = ie_options
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值