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