简体   繁体   English

Selenium将Firefox配置文件包含到远程驱动程序的DesiredCapabilities中

[英]Selenium include firefox profile into DesiredCapabilities for Remote Driver

My goal is to use a previously saved FireFox browser profile in Remore Webdriver at Selenium Grid. 我的目标是在Selenium Grid的Remore Webdriver中使用以前保存的FireFox浏览器配置文件

I've tried to add a profile object to DesiredCapabilities , yet failed, being a serialization error. 我尝试将配置文件对象添加到DesiredCapabilities ,但是失败了,这是一个序列化错误。 The following code I've composed based on this JAVA code : 我根据此JAVA代码编写了以下代码

desired_cap = {'acceptInsecureCerts': True, 'browserName': 'firefox',
           'marionette': True, 'browserstack.debug' : True}
profile_path= os.environ['APPDATA']+os.sep+os.path.join('Mozilla','Firefox','Profiles', 'rust_mozprofile.aaaabbbb')
profile_object = webdriver.FirefoxProfile(profile_path)
desired_cap['FirefoxDriver.PROFILE'] = profile_object

Error: ... File "C:\\Python27\\Lib\\json__init__.py", line 244, in dumps return _default_encoder.encode(obj) File "C:\\Python27\\Lib\\json\\encoder.py", line 207, in encode chunks = self.iterencode(o, _one_shot=True) File "C:\\Python27\\Lib\\json\\encoder.py", line 270, in iterencode return _iterencode(o, 0) File "C:\\Python27\\Lib\\json\\encoder.py", line 184, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: is not JSON serializable 错误:...在转储中,文件“ C:\\ Python27 \\ Lib \\ json__init __。py”第244行返回_default_encoder.encode(obj)文件“ C:\\ Python27 \\ Lib \\ json \\ encoder.py”的第207行,编码块= self.iterencode(o,_one_shot = True)文件“ C:\\ Python27 \\ Lib \\ json \\ encoder.py”,第270行,以iterencode返回_iterencode(o,0)文件“ C:\\ Python27 \\ Lib \\ json \\ encoder.py“,第184行,默认情况下引发TypeError(repr(o)+”不是JSON可序列化“”)TypeError:不是JSON可序列化

Any suggestions? 有什么建议么? Is it ever possible to pass Firefox profile to Remote Webdriver ? 是否有可能 将Firefox配置文件传递给Remote Webdriver

I load the profile locally with: 我在本地加载配置文件:

    self.browser = webdriver.Firefox(
        firefox_profile=profile_object,
    )

And remote. 和远程。

self.browser = webdriver.Remote(
        command_executor=SELENIUM,
        browser_profile=profile_object,
        desired_capabilities= desired_cap
    )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM