栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

selenium测试运行不会保存cookie?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/633133.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号