I'm testing an application where I am supposed to input an organization into a combo box. Once I click to another field, the system will then apply this logic: If the organization I entered does not exist in the application's database, a popup window will ask if I want to save it. If the organization was already present in the DB, no popup window displays.
My .NET script behaves correctly when I enter a new organization and click away; the popup opens and the script clicks 'Yes' in that window. But whenever the organization is already in the system, I get the playback error "XPath expression '@caption='New organization'' is invalid."
Can anybody determine what is wrong with my syntax for the If statement, or suggest a better alternative? I thought the script would begin at the next line after "End If" if the object doesn't exist.
Here are the relevant areas of the script:
Imports SilkTest.Ntf.Swt
Public Module Main
Dim _desktop As Desktop = Agent.Desktop
Public Sub Main()
With _desktop.Shell("@caption='Add Record'")
.ComboBox("[1]").TypeKeys("<OrganizationName>")
.TextField("[2]").Click
If .Shell("@caption='New organization'").Exists Then
With .Shell("@caption='New organization'")
.SetActive()
.PushButton("@caption='Yes'").Select()
End With
End If
.PushToolItem("@caption='Save and Close'").Select()
End With
End Sub
End Module