【发布时间】:2017-12-07 15:26:51
【问题描述】:
我的目标是在 Selenium Grid 的 Remore Webdriver 中使用以前保存的 FireFox 浏览器配置文件。
我尝试将配置文件对象添加到DesiredCapabilities,但失败了,这是一个序列化错误。以下代码是我基于this JAVA code编写的:
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
错误:...文件“C:\Python27\Lib\json__init__.py”,第 244 行,在 转储 返回 _default_encoder.encode(obj) 文件“C:\Python27\Lib\json\encoder.py”,第 207 行,编码 chunks = self.iterencode(o, _one_shot=True) 文件“C:\Python27\Lib\json\encoder.py”,第 270 行,在 iterencode return _iterencode(o, 0) File "C:\Python27\Lib\json\encoder.py",第 184 行,默认 raise TypeError(repr(o) + " is not JSON serializable") TypeError: is not JSON serializable
有什么建议吗? 是否有可能将 Firefox 配置文件传递给远程 Webdriver?
【问题讨论】:
-
您能考虑向我们更新您的确切用例吗?您是否尝试使用现有的 Firefox 配置文件?或者尝试创建一个新的 Firefox 配置文件?谢谢。
-
@DebanjanB,我尝试使用保存在文件夹
rust_mozprofile.aaaabbbb中的现有 FireFox 配置文件。 -
根据您的问题
goal is to use a previously saved FireFox browser profile检查我更新的答案。谢谢
标签: python selenium firefox selenium-grid