2011-07-13 63 views
0

我是一個初學者,嘗試使用eclipse和testng來學習一個教程。然而,看起來實際的測試並沒有得到執行,因爲它沒有導航到我的代碼中的網址。Selenium RC啓動Firefox5和IE8瀏覽器,但沒有去指定的網址

這是我輸入:

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 [email protected] 
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 [email protected] 
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瀏覽器打開一個空白的URL。對於IE8,它導航到本地臨時文件夾。

如何獲取它導航到指定的網址?

回答

0

你正在使用哪個版本的硒 - 獨立服務器? 你的lib文件夾中是否有stanalone服務器?請下載Selenium-server-standalone-2.0b3.jar並用現有的替換。讓我知道你還有什麼問題嗎?

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工作:)

謝謝, Safi

相關問題