51Testing软件测试论坛

标题: Selenium RC用Eclipse执行,总报Connection refused: connect [打印本页]

作者: csj    时间: 2011-7-4 11:41
标题: Selenium RC用Eclipse执行,总报Connection refused: connect
Exception in thread "main" java.lang.RuntimeException: Could not contact Selenium Server; have you started it on 'localhost:4445' ?
Read more at http://seleniumhq.org/projects/remote-control/not-started.html
Connection refused: connect
代码如下,求大侠支招
package SeScript;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class MainTest {
       
        /**
         * @param args
         */
        public static void main(String[] args) throws Throwable  {
                // TODO Auto-generated method stub
               
                System.out.println("ok");
                GoogleTest googleTest1=new GoogleTest();
                googleTest1.setUp();
                googleTest1.testGoogle();
                googleTest1.tearDown();
        }
       
       

       

}

class GoogleTest {
        private Selenium selenium;

        public void setUp() throws Exception {
        String url = "http://www.google.com";
        selenium = new DefaultSelenium("localhost", 4444, "*firefox", url);//4444 is default server port
        selenium.stop();
       
        selenium.start();
        }

        protected void tearDown() throws Exception {
        selenium.stop();
        }

        public void testGoogle() throws Throwable {
        selenium.open("http://www.google.com/webhp?hl=en");
        selenium.click("btnG");
        selenium.waitForPageToLoad("5000");

        }

        }
作者: ivwseeqg    时间: 2011-7-5 11:37
没有启动selenium-server
作者: ivwseeqg    时间: 2011-7-5 11:41
首先下载selenium-server.jar或者selenium-rc,然后在DOS下输入java -jar 安装包路径,启动成功即可!

C:\Documents and Settings\Administrator\桌面\study\selenium>java -jar e:\rc\sele
nium-server\selenium-server.jar
11:32:34.227 INFO - Java: Sun Microsystems Inc. 10.0-b19
11:32:34.243 INFO - OS: Windows XP 5.1 x86
11:32:34.337 INFO - v2.0 [a2], with Core v2.0 [a2]
11:32:34.931 INFO - RemoteWebDriver instances should connect to: http://127.0.0.
1:4444/wd/hub
11:32:34.931 INFO - Version Jetty/5.1.x
11:32:34.962 INFO - Started HttpContext[/selenium-server/driver,/selenium-server
/driver]
11:32:34.962 INFO - Started HttpContext[/selenium-server,/selenium-server]
11:32:34.962 INFO - Started HttpContext[/,/]
11:32:35.134 INFO - Started [url=mailtorg.openqa.jetty.jetty.servlet.ServletHandler@17182c]org.openqa.jetty.jetty.servlet.ServletHandler@17182c[/url]
1
11:32:35.134 INFO - Started HttpContext[/wd,/wd]
11:32:35.150 INFO - Started SocketListener on 0.0.0.0:4444
11:32:35.150 INFO - Started [url=mailtorg.openqa.jetty.jetty.Server@1c184f4]org.openqa.jetty.jetty.Server@1c184f4[/url]
作者: freedom2k    时间: 2011-9-5 13:45
要先启动server,然后再去跑你的用例
作者: wuhuawu09    时间: 2011-10-8 14:11
have you started it on 'localhost:4445' ?

先启动服务4445端口。




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2