web自动化测试

一、自动化测试的本质

  本质:用程序测试程序。通常。在设计了测试用例并通过评审之后,由测试人员根据测试用例中描述的规程一步步执行测试,得到实际结果与期望结果 比较。为了提高测试效率,便引入了自动化测试的概念。

  web自动化测试用的工具是selenium.

  selenium是一套完整的web应用程序测试系统,它包含了测试录制(selenium Ide )、编写及运行(selenium remote control)和测试的并行处理(selenium grid).

二、selenium的主要功能包括

  1、测试与游览器的兼容性:测试应用程序能否兼容工作在不同游览器和操作系统之中;

  2、测试体统功能:录制用例自动生成测试脚本,用于回归功能测试或者系统用例说明。简而言之,Selenium 就是一款可以录制用户操作,帮助 Web 测试人员简化重复劳动的工具。

三、selenium的版本

  1、selenium-core 是使用html的方式来编写测试脚本

  2、selenium-rc是selenium  remote control的缩写,支持多种语言。

四、xpath的学习

  xpath是在xml文档中查找信息的语言。

五、部分selenium-rc的使用技巧

  使用selenium-rc必须首先要启动selenium服务,在安装目录中的server目录下,运行selenium-server.jar,启动完毕后我们就可以编写测试类。

  selenium是模仿游览器的行为的,下面的代码作用是初始化一个selenium对象

public class TestPage2 extends TestCase {  
   private Selenium selenium;  
   protected void setUp() throws Exception {  
   String url = “http://xxx.xxx.xxx.xxx/yyy”;  
      selenium = new DefaultSelenium("localhost", SeleniumServer.getDefaultPort(),
      "*iexplore", url);  
      selenium.start();  
      super.setUp();                               
   }  
   protected void tearDown() throws Exception {         
      selenium.stop();  
      super.tearDown();  
   }  
} 

  rul:测试网站的地址

  localhost:可以不是localhost,但必须是selenium server的启动地址

  *iexplore:其他游览器类型,在网站上可以看都支持那些网站类型  

六、selenium-ide使用

  使用selenium-ide,要在火狐游览器中安装selenium的插件,只支持火狐游览器

原文地址:https://www.cnblogs.com/leilei0327/p/8127459.html