Selenium - 新手在迁移之前使旧版本工作

时间:2012-03-20 14:03:49

标签: unit-testing gwt selenium selenium-rc

我正在开发一个项目,它使用旧版本的Selenium - v0.9-2服务器。我将迁移到最新版本,但首先要求让这个版本先工作,当然要了解它的作用。这是我第一次使用这个框架

所以,我使用Java 1.6和FF V9在Eclipse Indigo下运行

我有两个eclipse启动文件,用于启动服务器然后进行测试。

所有测试都扩展了我们的自定义BaseTestCase类。

BaseTestCase不做任何其他事情,然后为测试设置内容。

以下是正在使用的配置设置

    private static String TEST_SERVER = "localhost";
    private static int TEST_SERVER_PORT = 5555;
//  private static String TEST_BROWSER = "*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe";
    private static String TEST_BROWSER = "*custom C:/Program Files (x86)/Mozilla Firefox/firefox.exe -firefoxProfileTemplate C:/temp/selenium-profile";
    public static String TARGET_URL = "http://w7001lt8001prd:9080";
    private static String TARGET_ROOT_PATH = "apps/gtgo.html";

利用第二个TEST_BROWSER设置,我现在能够启动FF,但测试仍未执行。

在这个类的setup方法中,我们用这种方式调用Selenium:

    selenium = new DefaultSelenium(TEST_SERVER, TEST_SERVER_PORT,TEST_BROWSER, TARGET_URL);
    selenium.start();

有一个方法用于打开根页面 - 然后将使用TARGET_ROOT_PATH

当我在这里启动服务器时输出:

(server.SeleniumServer               565 ) Java: Sun Microsystems Inc. 20.4-b02
(server.SeleniumServer               566 ) OS: Windows 7 6.1 amd64
(server.SeleniumServer               686 ) v0.9.2-SNAPSHOT [2001], with Core v0.8.3-SNAPSHOT [1875]
(http.HttpServer                     684 ) Version Jetty/5.1.x
(util.Container                      74  ) Started HttpContext[/selenium-server/driver,/selenium-server/driver]
(util.Container                      74  ) Started HttpContext[/selenium-server,/selenium-server]
(util.Container                      74  ) Started HttpContext[/,/]
(http.SocketListener                 204 ) Started SocketListener on 0.0.0.0:5555
(util.Container                      74  ) Started org.mortbay.jetty.Server@77df38fd

当我在这里启动测试套件时输出

(util.Credential                     60  ) Checking Resource aliases
(server.SeleniumDriverResourceHandler 391 ) Command request: getNewBrowserSession[*custom C:/Program Files (x86)/Mozilla Firefox/firefox.exe -firefoxProfileTemplate C:/temp/selenium-profile, http://w7001lt8001prd:9080] on session null
(server.SeleniumDriverResourceHandler 586 ) Launching session 605798

FF启动但我显示一个标签,表明它无法连接:Firefox无法建立与服务器的连接w7001lt8001prd:9080

这里有什么方向可以让它发挥作用。

1 个答案:

答案 0 :(得分:0)

事实证明,为了完成所有工作,需要安装正确版本的FireFox - 4.0或更低,同时将Firefox主目录放入路径中。一旦完成,我现在可以运行测试套件。下一步 - 迁移到版本2.