51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 4141|回复: 4
打印 上一主题 下一主题

Selenium RC用Eclipse执行,总报Connection refused: connect

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2011-7-4 11:41:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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");

        }

        }
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2011-7-5 11:37:06 | 只看该作者
没有启动selenium-server
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2011-7-5 11:41:02 | 只看该作者
首先下载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]
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2011-9-5 13:45:00 | 只看该作者
要先启动server,然后再去跑你的用例
回复 支持 反对

使用道具 举报

该用户从未签到

5#
发表于 2011-10-8 14:11:30 | 只看该作者
have you started it on 'localhost:4445' ?

先启动服务4445端口。
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-20 06:19 , Processed in 0.085350 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表