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

 

 

 

 

 

转载于:https://www.cnblogs.com/hbreset/archive/2013/05/27/3101319.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值