51Testing软件测试论坛

标题: 将SeleniumIDE转化成JAVA脚本,在RC环境下跑 报错 [打印本页]

作者: liuxincao861105    时间: 2014-10-22 17:40
标题: 将SeleniumIDE转化成JAVA脚本,在RC环境下跑 报错
firefox 33.0
ide:2.7.0
server-standalone 已启动
在线等答案,谢谢。
java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser
        at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:109)
        at com.testPage.setUp(testPage.java:17)
        at junit.framework.TestCase.runBare(TestCase.java:132)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser
        at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
        at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
        at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
        at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
        at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
        ... 15 more


作者: joykao    时间: 2014-10-22 23:56
你的firefox装在默认路径吗?方便看下你的代码么?
作者: liuxincao861105    时间: 2014-10-24 13:37
package com;

import junit.framework.TestCase;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class testPage extends SeleneseTestCase{
        private Selenium selenium;

        @SuppressWarnings("deprecation")
        @Before
        public void setUp() throws Exception {
                setUp("http://www.baidu.com","*firefox C:\\MozillaFirefox\\firefox.exe");
                //String url="www.baidu.com";
                //selenium = new DefaultSelenium("localhost",4444, "*firefox  C:\\MozillaFirefox\\firefox.exe", url);
                //selenium.start();
        }

        @Test
        public void testPage1() throws Exception {
                selenium.open("/");
                selenium.click("id=kw");
                String name=selenium.getTitle();
                System.out.println(name);
                selenium.setSpeed("100000");
                selenium.type("id=kw", "ruby");
                selenium.click("id=su");
                selenium.waitForPageToLoad("30000");
                selenium.click("link=Ruby_百度百科");
               
        }

        @After
        public void tearDown() throws Exception {
                selenium.stop();
        }
}

作者: joykao    时间: 2014-10-27 10:29
selenium.open("/");你把这句话去掉呗
作者: liuxincao861105    时间: 2014-10-27 17:35
liuxincao861105 发表于 2014-10-24 13:37
package com;

import junit.framework.TestCase;

好像可以运行了,谢谢。
作者: pcxty    时间: 2014-10-29 10:41
不错
作者: wang@1987    时间: 2015-6-5 09:29
楼主,我跟你遇到的是一样的问题,为什么我将selenium.open("/")去掉还是报错呢!?




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