The post Automate Java Swing Application appeared first on TestMate.
]]>The workflow starts on an already open Android Studio. It opens the Settings dialog from the File menu, performs some actions and closes it.
Any open source Object spy can be used to find object properties. Google acess bridge explorer can be a good option to spy objects.
'Open Settings Dialog from File Menu
java.VirtualClick("Role::frame,Name::r|My Application.*>==>Role::menu,Name::File")
java.Click("Role::frame,Name::r|My Application.*>==>Name::Settings...")
'Wait for Settings To Open - Polling wait for 20 seconds
bSync = java.Exist("Role::dialog,Name::Settings",20)
'Validate the presence of Settings Window
If bSync Then
Call Logger.Pass("Step 1","Dialog is present", True)
Else
Call Logger.Fail("Step 1","Dialog is not present", True)
End If
'Select Appearance node from Appearance & Behavior
Call java.SelectTreeNode("Role::dialog,Name::Settings>==>Role::tree","Name::Appearance & Behavior",0)
bSync = java.Exist("Role::dialog,Name::Settings>==>Role::combo box,Name::Theme:",20)
'Select DropDown Values
Call java.SelectFromCombobox("Role::dialog,Name::Settings>==>Role::combo box,Name::Theme:",1)
Call java.SelectFromCombobox("Role::dialog,Name::Settings>==>Role::combo box,Name::IDE:","Greyscale")
Call java.SelectFromCombobox("Role::dialog,Name::Settings>==>Role::combo box,Name::Editor:","Greyscale")
'Select Notifications tree Node
Call java.SelectTreeNode("Role::dialog,Name::Settings>==>Role::tree","Name::Appearance & Behavior",5)
bSync = java.Exist("Role::dialog,Name::Settings>==>Role::table,Visible::1",5)
'Validate the presence of notification Tables
If bSync Then
Call Logger.Pass("Step 1","Notifications table is present", True)
Else
Call Logger.Fail("Step 1","Notifications table is not present", True)
End If
'Check the required checkboxes in the table
'Since the Table object has already been located in the host in the previous step, we don need to pass it again
Call java.ClickTableCell(2,2)
Call java.ClickTableCell(4,2)
Call java.ClickTableCell(6,2)
Call java.ClickTableCell(7,2)
Call java.ClickTableCell(8,2)
Call java.ClickTableCell(9,2)
Call java.ClickTableCell(10,2)
Call java.ClickTableCell(11,2)
Call java.ClickTableCell(12,2)
Call java.ClickTableCell(13,2)
Call java.ClickTableCell(14,2)
Call java.ClickTableCell(15,2)
Call java.ClickTableCell(16,2)
Call java.ClickTableCell(17,2)
Call java.ClickTableCell(18,2)
Call java.ClickTableCell(19,2)
'Clic on the Popup cell and select Balloon
Call java.ClickTableCell(6,1)
util.Wait(100)
Call java.Click("Role::window>==>Name::Balloon")
'Click on Cancel button
'Virtyual click does not need mouse movement, but it is supported only by limited element types
Call java.VirtualClick("Role::dialog,Name::Settings>==>Role::push button,Name::Cancel")
The post Automate Java Swing Application appeared first on TestMate.
]]>The post Mouse Clicks & Key Press Using Testmate appeared first on TestMate.
]]>Mouse Click
'Perform mouse click on the entered x and y co ordinates
Call native.MouseClick(5,5)
Mouse Right Click
'Perform right mouse click on the entered x and y co ordinates
Call native.MouseClickRight(5,25)
Perform KeyPress
'Perform keypress on the passed virtual key
'0x14 - Caps Lock
Call native.KeyPress("0x14")
Perform KeyDown
'Perform key down on the passed virtual key
'0x14 - Caps Lock
Call native.KeyDown("0x14")
Perform KeyUp
'Perform key up on the passed virtual key
'0x14 - Caps Lock
Call native.Keyup("0x14")
List of all the virtual keys can be found here.
The post Mouse Clicks & Key Press Using Testmate appeared first on TestMate.
]]>The post How To Invoke External DLL’s | VBScript appeared first on TestMate.
]]>The below code demonstrates the usage of LoadAndRun method to invoke SetForegroundWindow method from user32.dl:
'Declare The DLL to be used
sDLL = "user32.dll"
'Declare the returrn type - Which is boolean
sRet = "bool"
'Declare the method string
sDec = "static extern bool SetForegroundWindow(IntPtr hWnd)"
'Fetch the handle of the application
hwndCalculator = Native.GetHandleByCaption("Calculator")
'Declare the Method string
sFunc = "SetForegroundWindow((IntPtr)" & hwndCalculator &" )"
'Run the method from the DLL
Call dll.LoadAndRun(sDLL,sRet,sDec,sFunc)
All the available DLL's and methods can be found here.
The post How To Invoke External DLL’s | VBScript appeared first on TestMate.
]]>The post Webdriver | Internet Explorer | Set Proxy Using Testmate appeared first on TestMate.
]]>VBScript
'Initialize the options (Optional but recommended)
Call wd.InitializeInternetExplorerOptions()
'Set HTTP Proxy value in the proxy object
Call wd.SetHTTP_Proxy("localhost:8888")
'Set Proxy for IE
Call wd.SetProxy_InternetExplorerOptions()
'Initialize IE driver (Pass the folder path to driver)
Call wd.InitializeInternetExplorerDriver("C:\Users\selenium")
'Navigate to the URLs
wd.NavigateToUrl("https://www.facebook.com/")
The post Webdriver | Internet Explorer | Set Proxy Using Testmate appeared first on TestMate.
]]>The post Webdriver | Launch Firefox Browser Using Testmate | Proxy appeared first on TestMate.
]]>Setup:
Make sure Geckodriver.exe file path is present in the Path system variable.
Firefox Default
InitializeFireFoxDriver method takes the path of gecko driver as a parameter
'Initialize Firefox driver
Call wd.InitializeFireFoxDriver("C:\Users\Desktop\selenium")
'Navigate the URL
wd.NavigateToUrl("https://www.facebook.com/")
Firefox Proxy
InitializeFireFoxDriver method takes the path of the gecko driver as a parameter.
'Initialize Firefox driver
wd.InitializeFireFoxOptions()
'initialize proxy
wd.InitializeProxy()
'Set HTTP proxy parameters
wd.SetHTTP_Proxy("localhost:8800")
'Set Proxy in firefox options
wd.SetProxy_FireFoxOptions()
'Initialize Firefox driver
Call wd.InitializeFireFoxDriver("C:\Users\Desktop\selenium")
The post Webdriver | Launch Firefox Browser Using Testmate | Proxy 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 | 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.
]]>