selenium测试运行不会保存cookie?

selenium测试运行不会保存cookie?,第1张

selenium测试运行不会保存cookie?

根据您的问题陈述,您面临的问题是硒正在打开一个未启用cookie的新的Firefox配置文件。

driver = new FirefoxDriver();

您必须在此处进行修复,以打开一个启用了cookie的配置文件。一种方法是在firefox中创建您自己的配置文件并打开该配置文件,而不是通过FirefoxDriver()直接打开;

ProfilesIni profileObj = new ProfilesIni();FirefoxProfile yourFFProfile = profileObj.getProfile("your profile");driver = new FirefoxDriver(yourFFProfile);

这样,您可以在该配置文件中进行所需的任何设置,并在该设置下运行测试。如果需要启用cookie,请在firefox选项中进行。

以下是根据seleniumhq.org打开特定配置文件的另一种方法

File profileDir = new File("path/to/top/level/of/profile");FirefoxProfile profile = new FirefoxProfile(profileDir);profile.addAdditionalPreferences(extraPrefs);WebDriver driver = new FirefoxDriver(profile);

检查源以获取有关此主题的更多信息。来源:http://docs.seleniumhq.org/docs/03_webdriver.jsp#modifying-
the-firefox-
profile



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5639004.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存