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 Save as PDF in Chrome | Testmate | Selenium appeared first on TestMate.
]]>Such scenarios can be easily handled using Testmate and can be triggered from your existing automation via command line.
Here is the sample code for it
''Declare all the Objects
oWindow = "Pane,Name::r|.*Google Chrome"
oCombo = "ComboBox,FrameworkId::Chrome"
oSaveBase = "Button,Name::Save"
oTextFileName = "Edit,Name::File name:"
oBtnSaveFile = "Window,Name::Save As>==>Button,Name::Save"
'Reset the root and set a RToot window
'This is optional method, it improves the execution speed
Call uia.ResetRoot()
Call uia.SetRoot(oWindow)
Call uia.SearchElementBySubtree()
'Select Value from dropdown
Call SelectValueFromDD(oCombo,"PDF")
Call uia.Click(oSaveBase)
'Wait for Save As dialog upto 20 Seconds
bSync = uia.Exist(oTextFileName,20)
'Save PDF
Call uia.SetValue(oTextFileName,"d:\test.pdf")
Call uia.Click(oBtnSaveFile)
'##############################################################################
'##############################################################################
'########################Cuatom Methods################################
'##############################################################################
'##############################################################################
'Since this is a custom dropdown , we need to handle it differently
Function SelectValueFromDD(Object,Value)
Call uia.Click(Object)
util.Wait(1)
'iCount = uia.GetSubtreeCount("ComboBox,FrameworkId::Chrome")
iCount = 5
Call MoveupDD(iCount)
For i =1 to iCount
sValue = uia.GetLegacyProperty(Object,"Value")
Call util.PrintOut(Value)
util.PrintOut(sValue)
If Instr(sValue,Value)>0 Then
Exit For
End If
native.KeyPress("0x28")
Next
Call uia.Click(Object)
End Function
Function MoveupDD(Iteration)
For i = 0 to Iteration + 1
native.KeyPress("0x26")
Next
End Function
The post Save as PDF in Chrome | Testmate | Selenium appeared first on TestMate.
]]>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 Appium | Automate iOS Application Using Testmate appeared first on TestMate.
]]>Setup
Read more about the selenium grid here.
'Reset the capabilities
app.InitializeOptions()
'Set the platform name
app.SetCapability "platformName", "iOS"
'set Device name
app.SetCapability "deviceName", "iPhone 7"
'Set Platform version
app.SetCapability "platformVersion", "11.2"
'set browser name
app.SetCapability "browserName", "Safari"
'Get IoS with Timeout Set as 300 seconds
Call app.GetIOSDriver("http://192.168.50.128:4723/wd/hub",300)
'Navigate to the URL
Call app.NavigateToUrl("http://www.google.com")
'Search the keyword
app.SendKeys "name::q", "Testmate Appium"
'Goto Teaser for Testmate
Call app.NavigateToUrl("https://www.youtube.com/watch?v=kijKozek5zs")
The post Appium | Automate iOS Application Using Testmate 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 Appium | Automate Android Application Using Testmate appeared first on TestMate.
]]>Setup
The below code invokes the default calculator on android, does some calculations and displays the result.
'Initialize Appium Options
app.InitializeOptions()
'Set Device Name
app.SetCapability "deviceName", "test"
'Set platform version
app.SetCapability "platformversion", "8.1"
'Set platform Name
app.SetCapability "platformname", "Android"
'Set platform Name
app.SetCapability "automationName", "Appium"
'Set Package Name
app.SetCapability "appPackage", "com.android.calculator2"
'Set Activity
app.SetCapability "appActivity", "com.android.calculator2.Calculator"
'Launch Driver - launch calculator
app.GetAndroidDriver "http://127.0.0.1:4723/wd/hub"
'Click on 8
app.Click "id::com.android.calculator2:id/digit_8"
'Click on X
app.Click "id::com.android.calculator2:id/op_mul"
'Click on 6
app.Click "id::com.android.calculator2:id/digit_6"
'Click on '='
app.Click "id::com.android.calculator2:id/eq"
'Display the result
Msgbox app.GetText("id::com.android.calculator2:id/result")
'Fetch the orientation
Msgbox app.GetOrientation
'Quit the driver
app.Quit()
The post Appium | Automate Android Application Using Testmate appeared first on TestMate.
]]>The post Webdriver | Launch Edge Browser Using Testmate | VBScript appeared first on TestMate.
]]>'Intialize edge Options
wd.InitializeEdgeOptions()
'Initialize edge Driver
wd.InitializeEdgeDriver("C:\Users\...\EdgeDriverPath")
'Navigate the URL
wd.NavigateToUrl("https://www.facebook.com/")
'Highlight the control
wd.Highlight("id::email")
'Send Keys in Email textbox
Call wd.SendKeys("id::email","abc")
'Send keys in Password
Call wd.SendKeys("id::pass","hello")
The post Webdriver | Launch Edge Browser Using Testmate | VBScript appeared first on TestMate.
]]>The post Webdriver | Execute JavaScript Using Testmate appeared first on TestMate.
]]>'Initialize the driver
Call wd.InitializeFireFoxDriver("C:\Users\Desktop\selenium")
'Navigate to the desired URL
Call wd.NavigateToUrl("https://www.google.com/")
'Execute javascript
Call wd.ExecuteScript("name::q","arguments[0].style.border='3px solid red'")
'Return page title using java script
Msgbox wd.ExecuteScript("return document.title")
The post Webdriver | Execute JavaScript Using Testmate appeared first on TestMate.
]]>The post Webdriver | Work With Multiple Browsers | Driver Parking appeared first on TestMate.
]]>''Park upto 5 instances of driver''
'Initialize the driver
Call wd.InitializeFireFoxDriver("C:\Users\jaska\Desktop\selenium")
'Navigate to the desired URL
Call wd.NavigateToUrl("https://www.google.com/")
'Park the current object instance in the reserved space - so that a new driver object can be created without loosing the old one
'FF driver - Parking Space 1
Call wd.ParkDriver1()
'Initialize IE Driver
Call wd.InitializeInternetExplorerDriver("C:\Users\jaska\Desktop\selenium")
'Navigate to the desired URL
Call wd.NavigateToUrl("https://www.google.com/")
'Park the current object instance in the reserved space - so that a new driver object can be created without loosing the old one
'IE driver - Parking Space 2
Call wd.ParkDriver2()
'Initialize Chrome Driver
Call wd.InitializeChromeDriver("C:\Users\jaska\Desktop\selenium")
'Navigate to the desired URL
Call wd.NavigateToUrl("https://www.google.com/")
'Type in Chrome
Call wd.SendKeys("name::q","This is Chrome")
'Switch Back to Internet Explorer
Call wd.UnParkDriver2()
'Type in IE
Call wd.SendKeys("name::q","This is IE")
'Switch Back to FireFox
Call wd.UnParkDriver1()
'Type in FireFOX
Call wd.SendKeys("name::q","This is Firefox")
The post Webdriver | Work With Multiple Browsers | Driver Parking appeared first on TestMate.
]]>