根据您的问题陈述,您面临的问题是硒正在打开一个未启用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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)