zoukankan      html  css  js  c++  java
  • TestComplete Study Note 3 Script Anny

    We can record a script or convert a keyword test to script or write a script directly. The former is much simpler.

    For general test, Keyword test is enough. But when we need to verify the data changes in database after the user do some operation on UI, we must use script to connect database. Keyword test will not meet such requirement.

    1. Query:

    var datauserid;
    var connstr="Provider=MSDASQL.1;Password=*****;Persist Security Info=True;User ID=xx;Data Source=xx;Initial Catalog=xx";                                                                                                                                                                   
    var Qry;
    Qry=ADO.CreateADOQuery();
    Qry.ConnectionString=connstr;
    Qry.SQL = "SELECT * FROM datauser WHERE firstname='xx' AND lastname='xx' AND loginUsername='xxxx'";

    // Call procedure

    //Qry.SQL = "call p_xxxxxxCounts("+campaignid+")"; 
     
      // Execute the query
      Qry.Open();  
      Qry.First();
      while (! Qry.EOF)
      {
        Log.Checkpoint("The checkpoint passed. "+ "The user '"+Qry.FieldByName("firstname").Value + " "+ Qry.FieldByName("lastname").Value+"' was added successfully in database");
        Log.Message("The datauserid is "+Qry.FieldByName("datauserid").Value);
        datauserid =  Qry.FieldByName("datauserid").Value;
        Qry.Next();
      };
      // Closes the query
      Qry.Close();
      if(null==datauserid)
         Log.Error("The checkpoint failed. "+"No such user 'limei li' was added in database");           
      else{...}

    2. Execute UID

        var conn;
        conn=ADO.CreateADOConnection();
        conn.ConnectionString=connstr;
        // Suppress the login dialog box
        conn.LoginPrompt = false;
        conn.open();
        conn.Execute_("delete FROM xxx WHERE datauserid="+datauserid); //sub table
        conn.Execute_("delete from xxxx where datauserid="+datauserid);   //main table
        conn.Close();

  • 相关阅读:
    HTML5/CSS3滑块动画菜单
    基于HTML5手机登录注册表单代码
    基于HTML5手机上下滑动翻页特效
    基于jQuery+HTML5页面整屏滑动切换代码
    基于html5可拖拽图片循环滚动切换
    基于html5背景图片自适应代码是一款背景不随滚动条滚动,会根据分辨率不同自动匹配对应的背景图片
    HTML5实现摇一摇
    html5桌面通知,notification的使用,右下角出现通知框
    html5全局属性
    HTML5 QQ登录背景动态图片
  • 原文地址:https://www.cnblogs.com/limei/p/2439275.html
Copyright © 2011-2022 走看看