如何在Selenium中使用已经打开的firefox进行测试 [英] How to use a already opened firefox for testing in Selenium

查看:507
本文介绍了如何在Selenium中使用已经打开的firefox进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此声明

WebDriver driver = new FirefoxDriver();

始终打开Firefox的新实例窗口。它没有使用已经打开的firefox。

always opens a new instance window of Firefox. It doesn't use the already opened firefox.

任何人都可以让我知道如何使用已经打开的firefox进行测试而不是打开一个新的吗?

Can anyone let me know how to use a already opened firefox for testing instead of opening a new one?

推荐答案

请注意,因为如果驱动程序崩溃一次,那么之后必须执行的所有测试用例都会受到影响,因为他们使用相同的驱动程序,你也将共享cookie,也许你之前已经打开的会话等等。

Be careful with that, because in case the driver crashes once, then all the test cases that have to be executed after that will be affected because they are using the same driver, also you will be sharing cookies, and perhaps sessions already opened previously, etc.

更强大的解决方案是为每个创建一个新的WebDriver测试用例,因为这样做可以使所有测试用例减少对其他测试用例的依赖。

The more robust solution is to create a new WebDriver for each test cases because doing that you are making all your tests cases less dependent on the others.

如果激励你的原因是每个WebDriver创建的时间,也许你可以开始考虑并行运行测试用例,例如使用TestNG。

If the reason that is motivating you is the time each WebDriver takes to be created, perhaps you could start thinking on run test cases in parallel for example with TestNG.

谢谢

这篇关于如何在Selenium中使用已经打开的firefox进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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