Brief Description
In the OEA 1.0-2.0 Framework, interfaces are developed based on the WPF technology. We need to perform automated testing on the developed system. NET platform's automated testing platform has not been completed by other departments within the company, so we developed a UI automation (UIA) using Ruby + vs uiunittest in 2010) framework, which is estimated to be UIA 1.0. UIA 1.0 is fully built by Zhou jingen. For details, refer to the articles he wrote.Article:
Use codedui of vs2010 to build your own Automated Testing Framework
Ironruby-automated test scripts
Information System Development Platform openexpressapp: [opentest] How to implement an automated testing framework
The test platform has implemented automated UI testing that is easy to read by testers.CodeIt is easy to use to meet routine automated testing requirements. The Department has been using it for about a year. Over time, it has also revealed some of its shortcomings:
- Debugging is difficult, maintenance costs are high, and it is difficult to add new UIA support.
- Procedural Code, not structured.
- It is not easy for the tester to develop. It does not support errors during compilation and there are too many repeated codes.
- Some statements have low performance.
For example, a lot of code similar to: "tab. Tab. Button" leads to multiple searches and tabs, with low performance.
- Customization is not supported.
- Difficult to deploy the test environment.
Only one test server has set up this environment. Developers cannot use UIA to assist themselves in self-testing.
In view of the above shortcomings, in September October, we decided to use the. NET environment to build the UIA framework, instead of Ruby, and try to be compatible with the historical code and API style written by testers.
Demo
Next, let's simply explain how UIA in OEA is used in one of our current modules.
The tester adds the UIA test class of a module to the UIA project. For example, the PBS template. CS is the test of this module:
The corresponding code is as follows:
Class PBS template: gix4 test case { Protected Override Void Run () {open the current test module (" Template management. PBS Template "); Add (); enter the window (" Add record ", Add record window =>{ Attribute Editor (" Encoding "). Input (" Autotest01 "); Attribute Editor (" Name "). Input (" Automated Testing-PBS Template "); Attribute Editor (" Remarks "). Input (" Test Template "); Click the button (" OK "); Save ();}); // #3 edit the PBS tree >>>> wait for the current row of the tree to be supported < Go to the tab (" PBS ", PBS tab =>{ tree OPERATION button Universal Test (); Save (); enter the tab ("Attribute ", Property tab => {tree OPERATION button Universal Test (); Save (); enter the tab (" Optional Value ", Optional value tab =>{ add (); List (). Current row (). Attribute Editor (" Optional Value "). Input (" Autotest "); Save (); copy and add (); Save (); press Ctrl (); List (). select a row (0); release CTRL (); Delete (); Save ();});}); // #6 load the tabs in the standard template window Click (" Load standard templates "); Enter the window (" Load standard templates ", Loading standard template window =>{ tab (" Sub-item "). Click (); tab (" Measure item "). Click (); tab (" Other projects "). Click (); tab (" Fee and Tax "). Click (); click (" OK ");});}); // #6 modify the PBS template information Click (" Modify "); Enter the window (" Modify ", Modify window =>{ Attribute Editor (" Encoding "). Input (" AutoTest01-1 "); Attribute Editor (" Name "). Input (" Automated Testing-PBS template-1 "); Attribute Editor (" Remarks "). Input (" Test template-1 "); Click the button (" OK ") ;}); Save (); Delete and confirm ();}}
The UIA test environment is a simple WPF applicatoin:
The software runtime interface corresponding to the previous Code:
UIA framework structure and related key points
The UIA framework is an important component of the entire OEA framework. Currently, only the UIA of the WPF client is implemented. The web UIA will be added as needed:
The Design of OEA-UIA is mainly based on the core class library in vs codeduitest for secondary encapsulation, provide more convenient OEA, more convenient tester many interfaces. Introduce the following class libraries:
The code is not complex. It is mainly used to add a series of extension methods on the relevant types of wpfcontrol (inherited from uitestcontrol). The following uses a button as an example:
Public Static Wpfbutton button ( This Wpfcontrol context, String Title = Null ){ Return Context. Find <wpfbutton> (title );} Public Static Wpfcontrol ( This Wpfcontrol Control) {control. ensureclickable (); control. waitforcontrolenabled (); mouse. Click (control ); Return Control ;} Public Static Tcontrol find <tcontrol> ( This Wpfcontrol context, String Title = Null ) Where tcontrol: wpfcontrol, New (){ // If (testcontext. Current. needcancel) playback. Cancel (); If (Testcontext. Current. needcancel) Throw New Stopuiaexception (" Stop automated testing! "); Var control = New Tcontrol (); If (Context! = Null ) {Control. Container = context ;} If (! String . Isnullorempty (title) {control. searchproperties [wpfcontrol. propertynames. Name] = title ;} Return Control ;}
In this way, you can use the. Button ("add") on any wpfcontrol container (for example, Tab A). Click.
Here,Note thatIn fact, uiautomationclient and uiautomationtypes are not unique to vs codeduitest.ProgramBut the automation framework assembly on the Windows platform. For more information, see msdn-accessibility in msdn. Based on this framework, we can theoretically perform automated testing for all applications on the Windows platform.
In UIA, the Windows Automation API is used for some lower-level control search scenarios. This is because vs codeduitest class library is used. Sometimes you cannot find the desired control, and you cannot make some in-depth customization for the oea wpf program. The currently developed web framework in OEA also uses it to build UIA.
Summary
In fact, this refactoring did not modify the entire structure of UIA 1.0. It mainly changed the language environment to the. NET environment, which makes it easier to add various features and better integrate with the OEA framework.
BTW: in fact, OEA-UIA has been completed and applied in last November, but because it has been developing the OEA framework in B/S mode, so it has not been released. But recently OEA-B/S has developed a rough, by the opportunity to write monthly reflection, write this document. Welcome to the discussion.