Twill: http://twill.idyll.org/
Selenium 使用介绍: http://www.iteye.com/topic/107276
官方网站: http://www.openqa.org/selenium/
中文资源: http://wiki.javascud.org/display/SEL/Home
Twillan安装请参阅python easy_install。附件有脚本。
示例脚本:
1.tw.twill:
go http://www.python.org/
showforms
setlocal query "twill Python"
go http://www.google.com/
fv 1 q $query
submit btnI # use the "I'm feeling lucky" button
show
2.Selenium Remote Control:
JiGou_TJ .java文件
package tests;
import java.util.Random;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
public class JiGou_TJ extends SeleneseTestCase {
private Selenium selenium;
public void setUp() throws Exception {
String url = "http://10.0.0.17:8080";
selenium = new DefaultSelenium("localhost", SeleniumServer
.getDefaultPort(), "*firefox", url);
selenium.start();
}
public void tearDown() throws Exception {
selenium.stop();
}
public void testJiGou_TJ() throws Exception {
selenium.open("/sia4/index.jspx");
selenium.click("link=登录");
selenium.waitForPageToLoad("30000");
selenium.type("j_username", "admin");
selenium.type("j_password", "password");
selenium.click("login");
selenium.waitForPageToLoad("30000");
int i =0;
while (i<10) {
selenium
.open("/sia4/Party/InternalOrganization.jspx?_action=create&_menuId=M_O1");
// 产生一个随机数
Random random = new Random();
int random_int = random.nextInt();
selenium.type("simpleName", "机构" + random_int);
selenium.type("externalReference", "100000" + random_int);
selenium.select("organizationType", "label=总公司");
selenium.select("organizationClass", "label=一级");
selenium.select("regionClass", "label=A类");
//selenium.type("deposit", "121" + random_int);
selenium.type("seqIndex", "1");
selenium.type("foundationDate", "2007-12-13");
selenium.type("parent_text", "中英人寿保险有限公司");
//selenium.waitForPageToLoad("300000");
for (int second = 0;; second++) {
if (second >= 60)
fail("timeout");
try {
if ("parent_text".equals(selenium.getValue("中英人寿保险有限公司")))
break;
} catch (Exception e) {
}
Thread.sleep(1000);
}
//Thread.sleep(5000);
selenium.selectWindow("null");
selenium.click("link=保存");
selenium.waitForPageToLoad("30000");
verifyTrue(selenium.isTextPresent("您的信息已成功更新"));
// Thread.sleep(5000);
i++;
Thread.sleep(5000);
}
}
}