Selenium+java分层(五)

来源:互联网 发布:简单php文件管理系统 编辑:程序博客网 时间:2024/05/24 07:06
基础的都写好了,反正分层的思想也很明确了,接下来就开始放大招了,用单元测试框架来玩了。
 1.在第四篇的基础上改进
(1)删除了com.selenium.test包,当初用来调试的包,无情的抛弃了,好像有点残忍
(2)新建com.selenium.testng包
(3)新建LoginTestng类,testng的jar我是集成在selenium中了,所以在途中没有看到引入,实际是引入了

 
2.LoginTestng代码如下
import com.selenium.action.LoginAction;
import com.selenium.basic.OpenBrowser;
public class LoginTestng{
    
    LoginAction login null;
      @BeforeMethod
      public void beforeMethod()  
          //初始化类,并打开链接
          login new LoginAction(OpenBrowser.Open("http://www.ymxh.com"));
      }
      
      @Test
      public void WapLoginA() {
          //成功登录
         login.Login("yuxm""123456");
      }
      
      @Test
      public void WapLoginB() {
          //用户不存在
          login.Login("yuxm1""123456");
      }
       
      @AfterMethod
      public void afterMethod(){
          //关闭浏览器
          login.ReturnDriver().close();
      } 
}  
原创粉丝点击