zoukankan      html  css  js  c++  java
  • for SBY

    In my opinion, all of test automation framework supply nearly the same function, the only difference is make a friendlier user interface. We master the principle of the tools and learn the methods form the tool author. For the web application automation, below code show the nature. This is part of training to my co-worker.

     1 [TestMethod]
     2         //Data-driven testing:read input/output data into test case form DB/excel/xml/csv
     3         //[DataSource("Driver={Microsoft Excel};Path={};DataAccessMethod.Sequential")]
     4         public void TC_IEDemo()
     5         { 
     6             //using mshtml;using SHDocVw;
     7             InternetExplorer ie = new InternetExplorer();
     8             ie.Visible = true;
     9             string url = "http://www.google.com";
    10 
    11             /*below code should be packaged to a helper class method: 
    12              * LaunchApp(Enum BrowserType), ie7-10;ff/Chrome/iOS 
    13             Process.Start("iexplore.exe", url);*/
    14             object nil = new object();
    15             ie.Navigate(url, ref nil, ref nil, ref nil, ref nil);
    16             Thread.Sleep(3000);//WaitForReady(int timeout)
    17 
    18             /* below code show the three key steps of an automation framework:
    19              Tips:
    20              1) make code strong: WaitForReady(int timeout); try/catch/finally
    21              2) application UI tree should serialize into XML and store into congif file
    22              3) package basic operation, such as each page need login
    23              4) User only need call high level methods: click-IEclick/FFclick/…
    24              5) Deal with the accident: win auto update */
    25             
    26             //1.Get the UI element tree and point to target element.
    27             HTMLDocument doc = ie.Document as HTMLDocument;
    28             HTMLInputElement tb_Serach = (HTMLInputElement)doc.getElementById("q");//byname,bygroupid
    29             tb_Serach.value = "evernote";
    30             HTMLInputElement btn_Search = (HTMLInputElement)doc.getElementById("btnSearch");
    31             
    32             //2.Simulate the user input: mouse, keyboard, touch, thinking time.
    33             btn_Search.click();//WaitForReady(int timeout)
    34 
    35             //3.Check the attribute of target element: name, value, status.
    36             HTMLInputElement btn_Status = (HTMLInputElement)doc.getElementById("btnStatus");
    37             Assert.AreEqual("res.enu.wintitle", btn_Status.title);//use resource file for Multiple languages
    38         }

    Windows desktop development technical evolution history: win32 SDK; Win Form; WPF/Silverlight,

    Test automation technical also changed with it, below show my experience.

    Mind map is on the way…

    Main technical

    Details Methods

    Comments(Disadvantage)

    Win32API HWND

    Win Message Win Hook

    FindWindowEx

    SendKey

    GetWindowText

    1.   Windows Spy++ is the famous   tool which use these
    2.   Win Hook is more powerful but   may course AUT crash or miss the bug
    3.   Tester need nearly the same technical   as Dev

    MSAA

    IAccessible:: accName

    Get_accChild/Parent…

    1.   AccExplorer
    2.   Need Dev implement the   IAccessible interface

    UIAutomation

    UIA Property: Name/ID…

    UIA Pattern: Select/Expand…

    UIA Event: OnComplete…

    1.   First real framework for test   automation, Win32API is for Dev and MSAA is for special people to use windows   application.
    2.   UISpy
  • 相关阅读:
    查询AD账号的SID
    Linux下NFS搭建实验
    定制windows环境下cmd替代软件ConEmu
    [转载]硬盘MBR详细介绍
    HP_UX扩dump空间
    zero和null以及sparse
    Cisco MDS9222i光纤交换机最常用排错命令
    Brocade SAN Switch上简单配置AG
    RHEL环境下调试Shell脚本时遇到字符串转换整数的问题
    Brocade SAN SWITCH配置文件导出和恢复
  • 原文地址:https://www.cnblogs.com/hbreset/p/3101319.html
Copyright © 2011-2022 走看看