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
  • 相关阅读:
    celery异步任务
    redis过期策略与内存淘汰机制分析
    爬虫数据去重-布隆过滤器
    scrapy-redis数据去重与分布式框架
    redis哨兵机制
    C#从零单排上王者系列---元组
    玩转VSCode插件之Remote-SSH
    C#从零单排上王者系列---数据类型
    Cassandra之Docker环境实践
    centos7安装nginx并配置前端环境
  • 原文地址:https://www.cnblogs.com/hbreset/p/3101319.html
Copyright © 2011-2022 走看看