public class Firefox extends SeleneseTestNgHelper {
@BeforeClass
public void setUp() throws Exception {
RemoteControlConfiguration cfg = new RemoteControlConfiguration();
File filefoxProfile=new File("D:\firefox-profile");
cfg.setPort(4444);
cfg.setReuseBrowserSessions(true);
cfg.setBrowserSideLogEnabled(true);
cfg.setSingleWindow(true);
cfg.setFirefoxProfileTemplate(filefoxProfile);
SeleniumServer server = new SeleniumServer(cfg);
server.start();
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.yihaodian.com/");
selenium.start();
}
//@Parameters({"username","password"})
@Test
public void test222() throws Exception {
selenium.open("https://passport.yihaodian.com/passport/login_input.do");
Thread.sleep(3000);
selenium.type("id=un", "aaa@163.com");//input username
selenium.type("id=pwd", "pwd");//input password
selenium.click("link=请登录");
Thread.sleep(3000);
//selenium.open("http://www.yihaodian.com/product/1017_1");//buy a product which id=1017 and warehouseID=1
}
}
用以上代码运行后,还是报错如下
com.thoughtworks.selenium.SeleniumException: Connection refused: connect
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:111)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:90)
at com.thoughtworks.selenium.DefaultSelenium.captureScreenshot(DefaultSelenium.java:719)
at com.thoughtworks.selenium.ScreenshotListener.onTestFailure(ScreenshotListener.java:27)
at com.thoughtworks.selenium.ScreenshotListener.onConfigurationFailure(ScreenshotListener.java:41)
at org.testng.internal.Invoker.runConfigurationListeners(Invoker.java:1842)
at org.testng.internal.Invoker.handleConfigurationFailure(Invoker.java:333)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:236)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.TestRunner.beforeRun(TestRunner.java:637)
at org.testng.TestRunner.run(TestRunner.java:605)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1142)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1067)
at org.testng.TestNG.run(TestNG.java:979)