关于selenium环境搭建问题
本帖最后由 fsweicaixia 于 2013-11-26 16:13 编辑初学,代码如下:package org.coderinfo.demo;
import com.thoughtworks.selenium.*;
@SuppressWarnings("deprecation")
public class TestEnv extends SeleneseTestCase {
public void setUp()throws Exception {
// setUp("http://www.baidu.com","googlechrome");
System.out.print("----开始执行-----");
selenium=new DefaultSelenium("192.168.13.10",8001,"*googlechrome","http://192.168.13.10:8001/login.aspx");
selenium.start();
}
public void testUntitled()throws Exception{
selenium.open("/");
selenium.type("q", "selenium");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
boolean testResult = (selenium.isTextPresent("Selenium web application testing system"));
if (testResult){
//用例成功
System.out.print("Search selenium web is ok!");
} else {
//用例失败
System.out.print("selenium web not found!");
}
}
public static void main(String[] args) throws Exception {
TestEnv st = new TestEnv();
st.setUp();
st.testUntitled();
}
}
----开始执行-----
Exception in thread "main" java.lang.RuntimeException: Could not start Selenium session: Not Found
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:109)
at org.coderinfo.demo.TestEnv.setUp(TestEnv.java:9)
at org.coderinfo.demo.TestEnv.main(TestEnv.java:28)
Caused by: com.thoughtworks.selenium.SeleniumException: Not Found
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:183)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:118)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:101)
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)
... 2 more
此问题是否因找不到包
还有是否要启动selenium-server.jar包 就是把selenium-java的jar包和这个jar所依赖的那个lib目录下的所有jar都添加到classpath里面去就行了 谢谢专一学习了selenium 理解了。
页:
[1]