如何在同一浏览器上重新运行Selenium 2.0(webdriver)测试? [英] How do I rerun Selenium 2.0 (webdriver) tests on the same browser?

查看:121
本文介绍了如何在同一浏览器上重新运行Selenium 2.0(webdriver)测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Selenium 2.0(Webdriver)来实现一系列测试。在运行这些测试之前,我必须登录该应用程序。由于应用程序不是我自己的(测试api构建的功能),因此每个测试都不应该登录到我的应用程序中运行。

I am trying to use Selenium 2.0 (Webdriver) to implement a series of tests. Before these tests can run, I have to login into the application. Since the application is not my 'own' (testing api-built functionality), each test should not be logging into my application to run.

我更愿意执行以下操作:

I would prefer to do the following:


  1. 将我的webdriver测试连接到我打开的Firefox浏览器(已登录)

  2. 使用相同的浏览器运行我的webdriver项目。

我知道Selenium通常会为其浏览器分配一个会话ID。但是,Selenium 2.0驱动程序的当前Java实现并未使用会话ID(可能确实如此,但我不知道在哪里可以找到它。)

I understand that Selenium usually assigns a session id to its browsers. However, the current Java implementation of Selenium 2.0 driver does not make use of session id (maybe it does but I don't know where to find it. )

可以有人提供一些指导如何解决我的问题(现有的浏览器和使用Selenium 2.0(java)运行多个测试)?提供的任何代码也会有所帮助。谢谢!

Can someone provide some direction on how to resolve my issue (existing browser and run multiple tests with Selenium 2.0 (java))? Any code provided would also be helpful. Thanks!

推荐答案

以下是我所学到的:

Selenium 1:正如Ioan早先建议的那样,在启动Selenium RC服务器时使用-firefoxProfileTemplate并指向Firefox配置文件的位置。

Selenium 1: As Ioan suggested earlier, use "-firefoxProfileTemplate" when starting up the Selenium RC server and point to the location of your Firefox profile.

Selenium 2:我想您可以使用Selenium 1 RC服务器,但是,由于Selenium 2使用WebDriver,您可以指向代码中的配置文件信息。

Selenium 2: I suppose you can use the Selenium 1 RC server, however, since Selenium 2 uses WebDriver, you can point to the profile information within your code.

File profileDir = new File("/Users/_____/selenium/FFprofile");
FirefoxProfile profile =
new FirefoxProfile(profileDir);
WebDriver driver = new FirefoxDriver(
    profile);

注意:


  1. 确保运行firefox -profilemanager来创建初始配置文件并保存您的登录信息。

  2. 允许浏览器/网站始终存储您的身份验证凭据,避免使用popup/loginwwindows等。

希望这可以帮助可能遇到类似问题的人:在Selenium中使用相同的浏览器配置文件等。

Hope this helps somebody who may run into a similar issue: Using the same browser profile in Selenium, etc.

这篇关于如何在同一浏览器上重新运行Selenium 2.0(webdriver)测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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