The post Desktop Automation Step By Step appeared first on TestMate.
]]>For all those who are looking for a free option to automate desktop applications, Testmate can be of imminent help.
Testmate is a VBScript based tool that simplifies the automation process for various applications (restricting our scope to only desktop applications such as .net, win32 & WPF in this article). It also provides inbuilt reporting and other framework components like OR etc.
Please find below the step by step guide to start with after you download Testmate:
1. Setting up Testmate
2. Knowing the reserved objects
3. Create objects for desktop application
4. Create the first test case Watch the video here
5. Object Repository
6. Automate calculator without Object repository
7. Set the main window as root to increase performance
Sample application and script
Download and extract the sample code below and copy it directly under C:
(To avoid any configuration, extract as C:\Sample or else manually change the path in config.xml file)
Then run it using testmate
The post Desktop Automation Step By Step appeared first on TestMate.
]]>The post UI Automation | Advance Script With OR appeared first on TestMate.
]]>Setup:
Repository
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<Objects>
<ky_Main>Window,Name::Form1
<ky_TabControl>Tab,AutomationId::tabControl1<ky_TabPage1>TabItem,Name::tabPage1</ky_TabPage1><ky_TabPage2>TabItem,Name::tabPage2</ky_TabPage2><ky_TabPage3>TabItem,Name::tabPage3</ky_TabPage3><ky_TabPane>Pane<ky_Tree>Tree</ky_Tree><ky_DataGrid>Table,AutomationId::dataGridView1</ky_DataGrid><ky_Checkbox1>CheckBox,AutomationID::checkBox1</ky_Checkbox1><ky_RadioButton1>RadioButton,AutomationID::radioButton1</ky_RadioButton1><ky_RadioButton2>RadioButton,AutomationID::radioButton2</ky_RadioButton2></ky_TabPane></ky_TabControl>
<ky_Textbox1>Edit,AutomationID::textBox1</ky_Textbox1>
<ky_Popup>Window<ky_OK_Button>Button,Name::OK</ky_OK_Button></ky_Popup>
<ky_Toolstrip1>Toolbar,Name::toolStrip1
<ky_Button1_TS>Button,Name::btn1</ky_Button1_TS><ky_List1>ComboBox</ky_List1></ky_Toolstrip1>
<ky_Button1>Button,Name::button1</ky_Button1>
</ky_Main>
</Objects>
VBScript
'Launch the app if not already launched.
If Not(uia.Exist("ky_Main")) Then
hwnd = util.StartApp("C:\Testmate\Sample\SampleTest.exe")
End If
'uia.SetRoot "ky_Main"
uia.SetRoot hwnd
'Select the tab
uia.Select("ky_TabPage1")
' Click on the button
uia.Click "ky_Button1"
'Fail the step if Popup Appears - Explicit failure for demonstration
If uia.Exist("ky_OK_Button",3) Then
Logger.Fail "Step 1", "Popup has been displayed", True
uia.Click "ky_OK_Button"
End If
'Set the Textbox value
uia.SetValue "ky_Textbox1" ,cstr(Time)
'Toggle the checkbox
uia.Toggle("ky_Checkbox1")
'Validate the Checkbox is checked
If uia.GetLegacyProperty("ky_Checkbox1","state")="1048596" Then
'Report the passed step
Logger.Pass "Step 2", "checkbox checked"
Else
'Report failure
Logger.Fail "Step 2", "checkbox checked",True
End If
'Click on radio button 2
uia.Click("ky_RadioButton2")
'Select Tab 2
uia.Select "ky_TabPage2"
'Perform Expand node operations on the the tree view
uia.ExpandTreeNode "ky_Tree" ,"Node0"
uia.ExpandTreeNode "ky_Tree" ,"Node0;Node2"
uia.ExpandTreeNode "ky_Tree", "Node0;Node2;Node3"
'Perform Select Node Operation
uia.SelectTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
uia.SelectTreeNode "ky_Tree" ,"Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
uia.SelectTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
uia.SelectTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
'Perform Expand select node operation
uia.ExpandTreeNode "ky_Tree", "Node1"
uia.SelectTreeNode "ky_Tree", "Node1;Node17"
'Collapse all the tree nodes
uia.CollapseTreeNode "ky_Tree", "Node0"
uia.CollapseTreeNode "ky_Tree", "Node0;Node2"
uia.CollapseTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.CollapseTreeNode "ky_Tree", "Node1"
'Select Value from the List view
uia.SelectFromDropDown "ky_List1" ,"Third"
'Select Third Tab
uia.Select "ky_TabPage3"
'Set the values in data grid
uia.SetCellData "ky_DataGrid", 1,1 ,Cstr(Time)
uia.SetCellData "ky_DataGrid",1,2 ,"Test"
uia.SetCellData "ky_DataGrid",1,3 ,Cstr(Time)
'Select The Tab
uia.Select("ky_TabPage1")
'Click on the button 1
uia.Click "ky_Button1"
'Handle popup
If uia.Exist("ky_OK_Button",3) Then
'Click Ok
uia.Click "ky_OK_Button"
End If
'Set the Textbox value
uia.SetValue "ky_Textbox1" ,cstr(Time)
'Toggle the checkbox
uia.Toggle("ky_Checkbox1")
'Validate the Checkbox is not checked
If uia.GetLegacyProperty("ky_Checkbox1","state")="1048596" Then
'Report the passed step
Logger.Fail "Step 3", "checkbox checked"'
Else
'Report failure
Logger.Pass "Step 3", "checkbox checked",True
End If
'Click on radio button 2
uia.Click("ky_RadioButton2")
'Select Tab 2
uia.Select "ky_TabPage2"
'Perform Expand node operations on the the tree view
uia.ExpandTreeNode "ky_Tree" ,"Node0"
uia.ExpandTreeNode "ky_Tree" ,"Node0;Node2"
uia.ExpandTreeNode "ky_Tree", "Node0;Node2;Node3"
'Perform Select Node Operation
uia.SelectTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
uia.SelectTreeNode "ky_Tree" ,"Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
uia.SelectTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
uia.SelectTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.SelectTreeNode "ky_Tree", "Node0;Node2"
'Perform Expand an select node operation
uia.ExpandTreeNode "ky_Tree", "Node1"
uia.SelectTreeNode "ky_Tree", "Node1;Node17"
'Collapse all the tree nodes
uia.CollapseTreeNode "ky_Tree", "Node0"
uia.CollapseTreeNode "ky_Tree", "Node0;Node2"
uia.CollapseTreeNode "ky_Tree", "Node0;Node2;Node3"
uia.CollapseTreeNode "ky_Tree", "Node1"
'Select Value from the List view
uia.SelectFromDropDown "ky_List1" ,"Third"
'Select Third Tab
uia.Select "ky_TabPage3"
'Set the values in data grid
uia.SetCellData "ky_DataGrid", 1,1 ,Cstr(Time)
uia.SetCellData "ky_DataGrid",1,2 ,"Test"
uia.SetCellData "ky_DataGrid",1,3 ,Cstr(Time)
'Reset the root
uia.ResetRoot
'Close the Window
uia.CloseWindow "ky_Main"
The post UI Automation | Advance Script With OR appeared first on TestMate.
]]>The post UI Automation | Set Root For AUT appeared first on TestMate.
]]>'Declare the root object
oWindow = "Window,Name::Calculator"
'By using this , the hierarchy can be skipped as below
oTwo = "Button,Name::Two"
oThree = "Button,Name::Three"
oFour = "Button,Name::Four"
oResult = "Text,AutomationId::CalculatorResults"
'Open Calculator App
Set oShell = CreateObject("Wscript.shell")
oShell.Run "Calc"
'Wait for the button to show up
bSync = uia.Exist(oWindow)
util.Wait(1)
'Set the parent window as root - This will improve the script performance
'All the objects will be located considering this window as root instead of desktop
uia.SetRoot oWindow
'Set algorithm to search anywhere under root
uia.SearchElementBySubtree()
'Click on 2,3,4 buttons
uia.Click oTwo
uia.Click oThree
uia.Click oFour
'Fetch the result
sText = uia.GetProperty(oResult,"Name")
'Make validation
If sText="Display is 234" Then
Logger.Pass "Step1", "Calculator displays correct result", True
Else
Logger.Fail "Step1", "Calculator displays incorrect result as" & sText, True
End If
'Set the desktop as the default Parent
uia.ResetRoot
The post UI Automation | Set Root For AUT appeared first on TestMate.
]]>The post UI Automation | Basic Script | Calculator appeared first on TestMate.
]]>'Describe the object properties
oWindow = "Window,Name::Calculator"
oTwo = "Window,Name::Calculator>==>Button,Name::Two"
oThree = "Window,Name::Calculator>==>Button,Name::Three"
oFour = "Window,Name::Calculator>==>Button,Name::Four"
'Open Calculator App
Set oShell = CreateObject("Wscript.shell")
oShell.Run "Calc"
'Wait for Window to show up
bSync = uia.Exist(oWindow)
util.Wait(1)
'Click on 2,3,4 buttons
uia.Click oTwo
uia.Click oThree
uia.Click oFour
The post UI Automation | Basic Script | Calculator appeared first on TestMate.
]]>