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.
]]>