????Client?????????????ant build????????JUnit??TestCase??????????TestCase?е?test???????????????server???????????????Client??????????????????£?

 

package com.tail.p2test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class DemoTest extends TestCase {
private Selenium selenium;
public void setUp() throws Exception {
String url = "http://localhost:8080/";
selenium = new DefaultSelenium("localhost"?? 4444?? "*chrome"?? url);
selenium.start();
}
protected void tearDown() throws Exception {
selenium.stop();
}
public void testNew() throws Exception {
selenium.setTimeout("100000");
selenium.open("/login.action");
selenium.type("username"?? "admin");
selenium.type("password"?? "123");
selenium.click("//input[@value='Log In']");
selenium.waitForPageToLoad("100000");
Thread.sleep(10000);
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (selenium.isElementPresent("signLabel")) break; } catch (Exception e) {}
Thread.sleep(1000);
}
// omit lines
...
selenium.open("/main.action");
}
}