zoukankan      html  css  js  c++  java
  • 检查对象是否存在

    第一种:最简单的一种

    //检查对象是否存在

    1  //检查对象是否存在
    2          public static void checkElement()
    3          {
    4              bool find = repo.D_Login.登入页面.PasswordInfo.Exists(1000);
    5              Report.Info(find.ToString());
    6          }

    第二种:复杂点

    public static void checkElement()
    {
    
      bool find = Validate.Exists(repo.D_Login.登入页面.Password,"check object {0}",false);
      Report.Info(
    "登录成功!");
    }

    这种方法有一个缺点,在找不到对象的时候,会抛出异常,需要加上try catch

     1    //判断系统是否登录成功
     2         public static bool JudgeIsLogin()
     3         {
     4             bool isLogin = false;
     5             try
     6             {
     7                 isLogin = Validate.Exists(repo.D_Login.登入页面.Password,"check object {0}",false);
     8                 Report.Info("登录成功!");
     9             }
    10             catch(Exception)
    11             {
    12                 isLogin = false;
    13                 Report.Info("登录失败");
    14             }
    15             
    16             return isLogin;
    17         }

      

  • 相关阅读:
    敏捷软件开发实践-Code Review Process(转)
    随笔1
    随笔
    随笔
    低级错误
    随笔
    随笔2
    随笔
    这以前写的代码
    蛋疼的vs
  • 原文地址:https://www.cnblogs.com/tanghuang/p/6383067.html
Copyright © 2011-2022 走看看