Selenium RC启动Firefox5和IE8浏览器,但没有转到指定的URL

时间:2011-07-13 20:55:51

标签: eclipse selenium selenium-rc testng

我是selenium的初学者,尝试使用eclipse和testng来学习。但是,似乎实际测试没有执行,因为它没有导航到我的代码中的url。

这是我的意见:

package script;

import com.thoughtworks.selenium.*;

import org.junit.AfterClass;
import org.testng.annotations.*;
import org.openqa.selenium.server.SeleniumServer;


public class Baseline extends SeleneseTestCase {

    @BeforeClass 
    public void setUp() throws Exception {
        SeleniumServer seleniumserver = new SeleniumServer();
        seleniumserver.boot();
        seleniumserver.start();
        setUp("http://www.google.com", "*iexplore");

    }

    @Test 
    public void testBaseline(){
        selenium.open("/");
        selenium.windowMaximize();
        selenium.windowFocus();
        selenium.type("q", "selenium rc");
        selenium.click("btnG");
        selenium.waitForPageToLoad("30000");
        assertTrue(selenium.isTextPresent("Results * for selenium rc"));
    }

    @AfterClass 
    public void tearDown(){
        selenium.close();
        selenium.stop();

    }
}

testng的输出:

16:44:10.326 INFO - Java: Sun Microsystems Inc. 20.1-b02
16:44:10.328 INFO - OS: Windows 7 6.1 x86
16:44:10.339 INFO - v2.0 [a2], with Core v2.0 [a2]
16:44:10.459 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
16:44:10.461 INFO - Version Jetty/5.1.x
16:44:10.461 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
16:44:10.462 INFO - Started HttpContext[/selenium-server,/selenium-server]
16:44:10.462 INFO - Started HttpContext[/,/]
16:44:10.503 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@1be2d65
16:44:10.503 INFO - Started HttpContext[/wd,/wd]
16:44:10.506 INFO - Started SocketListener on 0.0.0.0:4444
16:44:10.506 INFO - Started org.openqa.jetty.jetty.Server@32fb4f
16:44:10.563 INFO - Checking Resource aliases
16:44:10.570 INFO - Command request: getNewBrowserSession[*iexplore, http://www.google.com, ] on session null
16:44:10.572 INFO - creating new remote session
16:44:10.695 INFO - Allocated session 4a50ca969de04033b77cdb88dfd8af1a for http://www.google.com, launching...
16:44:11.106 INFO - Launching Embedded Internet Explorer...
16:44:12.126 INFO - Launching Internet Explorer HTA...

程序不会终止。

对于firefox,浏览器会打开一个空白网址。对于IE8,它导航到本地临时文件夹。

如何让它导航到指定的网址?

2 个答案:

答案 0 :(得分:0)

您使用的是哪种版本的selenium-standalone-server? 你的lib文件夹上有stanalone服务器吗?。请下载Selenium-server-standalone-2.0b3.jar并替换现有服务器。让我知道你有任何问题吗?

答案 1 :(得分:0)

出色!!!我发现问题时遇到了很多麻烦。事实证明我使用的Selenium Server jar文件已经过时了。此外,不推荐使用上面提到的Selenium-server-standalone-2.0b3.jar。因此,从Mani的上述答案中获取提示,转到此链接http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.3.0.jar&can=1&q=Selenium-server-standalone并下载selenium-server-standalone-2.3.0.jar并将其替换为旧的selenium-server.jar文件。瞧...现在firefox4和firefox5工作:)

谢谢, 萨菲