MTAS is an End-to-End Test Automation software framework compatible for virtually testing any hardware, device or embedded system throughout the entire product lifecycle. MSys Test solution has different plugins that test in Microsoft Visual Studio and supports Technologies including Web 2.0, Flex, Java, .NET,SSH/Telnet, and SQL Database. The following are the other features of MSys Test Automation Solutions: System integration testing for web applications Record and Play feature for Web, Windows, Flex, Siebel, Database, and SSH testing Execution of Testcases performed as a stand-alone application or using MTAS plug in Data Driven Testing - Import/Export data from XML, XLS and CSV Files Windows Automations How to record an application Once after installing MTAS, open visual studio, click new project and select MTAS and MTAS project. MTAS project template get loaded. go to solution Explorer and open TestCases Folder, by default we will be having two test class. Open TestCase2.cs class and right click on Execute method, under MTAS select Windows Recorder Option will be asked, do you want to record from desktop or run a Application. I had selected to run a sample application. Done some basic recording C# Edit|Remove csharpWinAgent.Load(@"C:\Users\Balaji\Desktop\exe\WinFormsTestApp.exe");logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " +Repo.WinRepo.MenuItem.MnuitemFile);WinAgent.Click(Repo.WinRepo.MenuItem.MnuitemFile);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " +Repo.WinRepo.MenuItem.MnuitemClickMe);WinAgent.Click(Repo.WinRepo.MenuItem.MnuitemClickMe);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " +Repo.WinRepo.Button.Btnbuton);WinAgent.Click(Repo.WinRepo.Button.Btnbuton);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Toggle the CheckBox of " +Repo.WinRepo.CheckBox.ChkchequeBox);WinAgent.ToggleCheck(Repo.WinRepo.CheckBox.ChkchequeBox);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " +Repo.WinRepo.Button.BtnOpen);WinAgent.Click(Repo.WinRepo.Button.BtnOpen);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Double Click of " +Repo.WinRepo.List.LstComboLBox);MouseOperations.ClickableDoubleLeftMouse(Repo.WinRepo.List.LstComboLBox);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Toggle the CheckBox of " +Repo.WinRepo.CheckBox.ChkBillGates);WinAgent.ToggleCheck(Repo.WinRepo.CheckBox.ChkBillGates);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Toggle the CheckBox of " +Repo.WinRepo.CheckBox.ChkNarayanMurthy);WinAgent.ToggleCheck(Repo.WinRepo.CheckBox.ChkNarayanMurthy);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " +Repo.WinRepo.RadioButton.RdbtnradioButton2);WinAgent.Click(Repo.WinRepo.RadioButton.RdbtnradioButton2);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " +Repo.WinRepo.Button.BtnClose);WinAgent.Click(Repo.WinRepo.Button.BtnClose);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " +Repo.WinRepo.Button.BtnNotificationChevron);WinAgent.Click(Repo.WinRepo.Button.BtnNotificationChevron);logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Set the value to " +Repo.WinRepo.Edit.EdttextBoxInsidePanel);WinAgent.SetValue(Repo.WinRepo.Edit.EdttextBoxInsidePanel, "setName"); WinAgent.Load(@"C:\Users\Balaji\Desktop\exe\WinFormsTestApp.exe"); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " + Repo.WinRepo.MenuItem.MnuitemFile); WinAgent.Click(Repo.WinRepo.MenuItem.MnuitemFile); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " + Repo.WinRepo.MenuItem.MnuitemClickMe); WinAgent.Click(Repo.WinRepo.MenuItem.MnuitemClickMe); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " + Repo.WinRepo.Button.Btnbuton); WinAgent.Click(Repo.WinRepo.Button.Btnbuton); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Toggle the CheckBox of " + Repo.WinRepo.CheckBox.ChkchequeBox); WinAgent.ToggleCheck(Repo.WinRepo.CheckBox.ChkchequeBox); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " + Repo.WinRepo.Button.BtnOpen); WinAgent.Click(Repo.WinRepo.Button.BtnOpen); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Double Click of " + Repo.WinRepo.List.LstComboLBox); MouseOperations.ClickableDoubleLeftMouse(Repo.WinRepo.List.LstComboLBox); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Toggle the CheckBox of " + Repo.WinRepo.CheckBox.ChkBillGates); WinAgent.ToggleCheck(Repo.WinRepo.CheckBox.ChkBillGates); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Toggle the CheckBox of " + Repo.WinRepo.CheckBox.ChkNarayanMurthy); WinAgent.ToggleCheck(Repo.WinRepo.CheckBox.ChkNarayanMurthy); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " + Repo.WinRepo.RadioButton.RdbtnradioButton2); WinAgent.Click(Repo.WinRepo.RadioButton.RdbtnradioButton2); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " + Repo.WinRepo.Button.BtnClose); WinAgent.Click(Repo.WinRepo.Button.BtnClose); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of " + Repo.WinRepo.Button.BtnNotificationChevron); WinAgent.Click(Repo.WinRepo.Button.BtnNotificationChevron); logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Set the value to " + Repo.WinRepo.Edit.EdttextBoxInsidePanel); WinAgent.SetValue(Repo.WinRepo.Edit.EdttextBoxInsidePanel, "setName"); Advantage of MTAS One actions done in one step code(less amount of code), Xpath stored in Object repository, Reuse of Xpath from Object repository, No need to search for Xpath & Screenshot, repo viewer selected item get updated automatically on code selected change, provide intellisense & validation while editing xpath.
Tips and tricks for better automation 1. Xpath internal search option:
This option lets you contract large Xpath names so that the generated script is cleaner and more readable [Name='Calculator']/[Class='CalcFrame']/[Name='4']
It can be change into [Name='Calculator']/../[Name='4']
Advantage of doing this, Even ifCalcFrame class get removed while application developent automation will still work
2. Contains Search option: In some cases a part of the name or the text of an element will change dynamically. This option can be used to search for and identify a dynamically changing element. var btnClose1 = new AutoElementTree("[Name='MDIParen1']"); var btnClose1 = new AutoElementTree("[Name='MDIParen', ContainsSearch=true']);
3. Click and Enter, Select and Enter option: Some controls may not support playback of click events performed while recording test steps. In such cases, we need to use the Click and Enter option to enforce such kind of click events on playback.
Event Description Code click Enter WinAgent.ClickAndEnter(btnactionConfirmDeleteAccount); select Enter WinAgent.SelectAndEnter(lstDesktop1,"WinFormsTestApp.exe - Shortcut); 4. Mouse Option Some controls may not support playback of click events performed while recording test steps. In such cases, we need to use the mouse option to enforce such kind of click events on playback. Event Description Code WinAgent.Click(btnactionConfirmDeleteAccount); Mouse click WinAgent.Click(btnactionConfirmDeleteAccount, true); Mouse Double click MouseOperations.ClickableDoubleLeftMouse(btnactionConfirmDeleteAccount); Mouse Right click MouseOperations.ClickableRightMouse(btnactionConfirmDeleteAccount); Mouse left click MouseOperations.ClickableLeftMouse(btnactionConfirmDeleteAccount); Sample Code:
C# Edit|Remove csharpvar lstDesktop1 = new AutoElementTree(@"[Name='Program Manager']/[Name='Desktop',Class='SysListView32', Type='List']/[Name='WinFormsTestApp.exe - Shortcut']") var btnClose1= new AutoElementTree(@"[ID='Form1']/[Type='TitleBar']/[Name='Close']")logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Select the item of lstDesktop.");WinAgent.Select(lstDesktop1, "WinFormsTestApp.exe - Shortcut");//select desktop itemlogger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Double Click of lstDesktop.");MouseOperations.ClickableDoubleLeftMouse(lstDesktop1);//double click itlogger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of btnClose.");WinAgent.Click(btnClose1);// close appMouseOperations.ClickableRightMouse(lstDesktop1);//right click using mouse var lstDesktop1 = new AutoElementTree(@"[Name='Program Manager']/[Name='Desktop', Class='SysListView32', Type='List']/[Name='WinFormsTestApp.exe - Shortcut']") var btnClose1 = new AutoElementTree(@"[ID='Form1']/[Type='TitleBar']/[Name='Close']") logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Select the item of lstDesktop."); WinAgent.Select(lstDesktop1, "WinFormsTestApp.exe - Shortcut");//select desktop item logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Double Click of lstDesktop."); MouseOperations.ClickableDoubleLeftMouse(lstDesktop1);//double click it logger.WriteLog("Debug Log", LOGLEVEL.DEBUG, "Triggers the Click Events of btnClose."); WinAgent.Click(btnClose1);// close app MouseOperations.ClickableRightMouse(lstDesktop1);//right click using mouse 5. Special Keys Option If certain actions performed by special keys or shortcut keys are not recognized while recording, this option can be used for special keys support during playback. Event Description Code Show desktop Screen WinAgent.ShowDesktop(); Open run Window WinAgent.PressSpecialKey("", SpecialKeys.LWIN, "r"); Type calc in upper case WinAgent.PressSpecialKey("", SpecialKeys.SHIFT, "calc"); Set Focus value to Calculator WinAgent.SendKeyStroke(Calculator, "1+2="); Mouse Right click MouseOperations.ClickableRightMouse(btnactionConfirmDeleteAccount); Mouse left click MouseOperations.ClickableLeftMouse(btnactionConfirmDeleteAccount); Send enter event WinAgent.SendEnter();
Sample Code C# Edit|Remove csharpvar Calculator = new AutoElementTree(@"[Name='Calculator']/[Class='CalcFrame']");WinAgent.ShowDesktop();WinAgent.PressSpecialKey(string.Empty, SpecialKeys.LWIN, "r");WinAgent.PressSpecialKey(string.Empty, SpecialKeys.SHIFT, "calc"); WinAgent.SendEnter();WinAgent.SendKeyStroke(Calculator, "1+2=");WinAgent.PressSpecialKey(Calculator, "", SpecialKeys.ALT, SpecialKeys.F4); var Calculator = new AutoElementTree(@"[Name='Calculator']/[Class='CalcFrame']"); WinAgent.ShowDesktop(); WinAgent.PressSpecialKey(string.Empty, SpecialKeys.LWIN, "r"); WinAgent.PressSpecialKey(string.Empty, SpecialKeys.SHIFT, "calc"); WinAgent.SendEnter(); WinAgent.SendKeyStroke(Calculator, "1+2="); WinAgent.PressSpecialKey(Calculator, "", SpecialKeys.ALT, SpecialKeys.F4); 6. Default Action This option can be used to perform a default action during playback. For example, double click is the default action to be performed to open a folder while a single click is the default action to select a folde WinAgent.DefaultAction(btnactionConfirmDeleteAccount); MTAS Case Viewer The MTAS Case viewer allows users to replace hard coded values in a test case with parameters using theMapper. This feature facilitates data driven testing as multiple iterations of the same test case can betested with different data sets. After Mapping data
With this option we can run testmethod "Execute" more than once with different set of value Alternatively, these parameters values can also be added manually or imported from an external data source in formats such as XML, XSL or CSV files. Assertion MTAS recorder will not do any direct assertion, but we can do it easy by some simple steps. 1. Click on the label or element you want to assertion 2. Stop Recording, Check for Xpath(AutoElementTree) or set or getValue code 3. Convert the code to WinAgent.IsExist(Calculator, "4"); Assert.IsTrue(WinAgent.IsExist(Calculator, "4"));
|