使用Selenium/Ant做Web应用远程自动化测试
作者:网络转载 发布时间:[ 2014/6/5 11:02:16 ] 推荐标签:Selenium 自动化测试工具
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 {
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");
}
}
|
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系SPASVO小编(021-61079698-8054),我们将立即处理,马上删除。
相关推荐
两种自动化测试工具AutoRunner与Selenium的对比关于Selenium自动化测试框架的较佳设计模式关于Selenium自动化测试框架那些你不知道的事哪种场景下,需要维护Selenium自动化测试过程?如何对Selenium自动化测试框架进行维护?Selenium自动化测试框架在自动化测试中发挥哪些作用?如何使用自动化测试框架ATF执行Selenium脚本?自动化测试脚本怎么写?如何使用Selenium录制浏览器的脚本?Selenium自动化测试框架软件好用吗?Selenium自动化测试框架ATF是如何根据数据生成用例的?多功能Selenium自动化测试框架软件ATFJava版本的Selenium异常记录第一个UI脚本-Python+Selenium实例:用Selenium和用Webdriver构建出来的测试工程如何放慢Selenium的运行速度Selenium FF WebDriver运行时开启firebug的2种方式
更新发布
常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11系统性能测试及调优前期准备
2021/4/15 14:41:29国内比较好用的5款测试管理工具
2021/3/25 17:23:31热门文章
常见的移动App Bug??崩溃的测试用例设计如何用Jmeter做压力测试QC使用说明APP压力测试入门教程移动app测试中的主要问题jenkins+testng+ant+webdriver持续集成测试使用JMeter进行HTTP负载测试Selenium 2.0 WebDriver 使用指南