带有配置文件的FirefoxDriver测试的并行执行共享同一配置文件副本 [英] Parallel execution of FirefoxDriver tests with profile share same profile copy

查看:93
本文介绍了带有配置文件的FirefoxDriver测试的并行执行共享同一配置文件副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我们一直在使用FirefoxDriver执行基于WebDriver 2.25.0的一组自动化测试.这些测试是由基于Maven 3.0的版本及其FailSafe插件并行执行的(四核计算机上,每个内核2个线程).每个测试都有一个@BeforeClass方法,该方法检索FirefoxDriver的实例并清除所有cookie.所有这一切都很好.

由于更改了代理身份验证(以前没有进行过更改),因此我们现在需要使用特定的Firefox配置文件运行测试.配置文件已创建,并且构建现在包含-Dwebdriver.firefox.profile =环境变量.该配置文件似乎已被提取,因为我们没有收到任何找不到配置文件"错误.但是,似乎每个Firefox实例都使用相同的配置文件副本,因此共享相同的cookie存储:应用程序应在用户首次访问时提供区域选择对话框,但在运行这些测试时则不提供. >

更新:在没有-Dwebdriver.firefox.profile变量并且使用新的FirefoxDriver(new ProfilesIni().getProfile(< profileName>"))的情况下,行为相同./p>

FirefoxDriver不是创建指定配置文件的副本并使用该隔离的副本运行每个Firefox实例吗?

谢谢!

解决方案

  • 如果您在实例化FirefoxDriver时未提供配置文件,则在运行代码new FirefoxDriver(...)时,将在C:\Users\#TheUser\AppData\Local\Temp文件夹内创建一个匿名配置文件,名为例如. anonymous1864251113973276405webdriver-profile.
  • 如果您提供FirefoxDriver的配置文件,则行为是相同的,只是配置文件副本被命名为: userprofile6938771758695790613copy.

最后,Webdriver总是在此Temp文件夹中创建配置文件的副本,即使您指定或不使用必须使用的自定义配置文件也是如此.关于cookie,每个创建的配置文件内部都有一个名为cookies.sqlite的文件.我不确定100%Cookie是否会以某种方式干扰,它们应该不会.您可以使用以下方法通过比较保存在每个网络驱动程序中的cookie进行检查:

 Set<Cookie> webDriverCookies = webDriver.manage().getCookies();

For a while now we've been executing a set of automated tests based on WebDriver 2.25.0 using the FirefoxDriver. The tests are executed in parallel (2 threads per core on a quad-core machine) by a Maven 3.0-based build and its FailSafe plugin. Every test has a @BeforeClass method that retrieves an instance of the FirefoxDriver and clears all cookies. All this is working fine.

Because of changes to proxy authentication (there was none before), we now need to run the tests using a particular Firefox profile. The profile was created, and the build now includes the -Dwebdriver.firefox.profile= environment variable. The profile seems to be picked up since we're not getting any "profile not found" error. However, it seems that every Firefox instance is using the same copy of the profile and therefore is sharing the same cookie store: the application should be offering a region selection dialog on a user's first visit but doesn't when running those tests.

Update: The behaviour is the same when running without the -Dwebdriver.firefox.profile variable and using new FirefoxDriver(new ProfilesIni().getProfile("<profileName>")) .

Isn't the FirefoxDriver creating a copy of the specified profile and running each Firefox instance using that isolated copy?

Thanks!

解决方案

  • If you do not provide a profile while instantiating FirefoxDriver, then when you run the code : new FirefoxDriver(...) , an anonymus profile is created inside C:\Users\#TheUser\AppData\Local\Temp folder , named e.g. anonymous1864251113973276405webdriver-profile.
  • If you provide a profile for FirefoxDriver, then the behavior is the same, excepting the fact that profiles copies are named : e.g. userprofile6938771758695790613copy.

In conclusion, Webdriver always creates a copy of a profile within this Temp folder even you specify or not a custom profile which has to be used. Regarding cookies, every created profile has a file named cookies.sqlite inside. I'm not 100% sure if cookies interfere in a way or another, they should not. You can check by comparing cookies saved in every webdriver, using:

 Set<Cookie> webDriverCookies = webDriver.manage().getCookies();

这篇关于带有配置文件的FirefoxDriver测试的并行执行共享同一配置文件副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆