|
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");
}
} |
|