自动化测试

初学SELENIUM(1)

上一篇 / 下一篇  2007-09-15 19:46:17

听说(注意,是听说)SELENIUM用来做web测试不错,决定下来玩玩。先把selenium-remote-control(http://release.openqa.org/selenium-remote-control/0.9.0/selenium-remote-control-0.9.0.zip)下了下来,然后是JUNIT(http://downloads.sourceforge.net/junit/junit-4.4.jar?modtime=1184865382&big_mirror=0
),最后是JDK1.5,除了JDK,其他的好像没有版本上的限制,反正我都下了最新的,在CMD里启动selenium-server.jar(JAVA -JAR selenium-server.jar),打开ECLIPSE,新建一个项目,把JUNIT,SELENIUM,selenium-server的jar都放到构建路径,试着写了一个类,测试我本机的BLOG的登陆功能,YEAH,成功。


以下是代码:

package soucre;

import org.openqa.selenium.server.SeleniumServer;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

import junit.framework.TestCase;

public class TestPage2 extends TestCase {

 private Selenium selenium;

 protected void setUp() throws Exception {

  String url = "http://localhost/BLOG";

  selenium = new DefaultSelenium("localhost", SeleniumServer
    .getDefaultPort(), "*iexplore", url);

  selenium.start();

  super.setUp();

 }

 protected void tearDown() throws Exception {

  selenium.stop();

  super.tearDown();

 }

 public void test1() {

  selenium.open("http://localhost/BLOG");

  selenium.type("xpath=//input[@name='username']", "admin");
  
  selenium.type("xpath=//input[@name='Password']", "admin");

  selenium.click("xpath=//input[@type='submit']");

  selenium.waitForPageToLoad("2000");

 }

}


最后是网上一些参考资料:

http://www.javaeye.com/topic/107276

http://www.openqa.org/selenium/

http://www.zvon.org/xxl/XPathTutorial/General_chi/examples.html


TAG: SELENIUM 自动化测试 AUTOMATION

 

评分:0

我来说两句

日历

« 2024-04-09  
 123456
78910111213
14151617181920
21222324252627
282930    

我的存档

数据统计

  • 访问量: 3971
  • 日志数: 6
  • 建立时间: 2007-09-05
  • 更新时间: 2007-09-28

RSS订阅

Open Toolbar