Within Silk4NET, literal references to identified objects are referred to as locators. For convenience, you can use shortened forms for the locator strings in scripts. Silk4NET automatically expands the syntax to use full locator strings when you playback a script. When you manually code a script, you can omit the following parts in the following order:
When you manually code a script, we recommend that you use the shortest form available.
VB
_desktop.DomLink("//BrowserApplication//BrowserWindow//a[@textContents='Home']").Select()
C#
_desktop.DomLink("//BrowserApplication//BrowserWindow//a[@textContents='Home']").Select();
To confirm the full locator string, use the Locator Spy dialog box.
VB
browserWindow.DomLink("//a[@textContents='Home']").Select()
C#
browserWindow.DomLink("//a[@textContents='Home']").Select();Alternatively, you can use the shortened form.
VB
browserWindow.DomLink("@textContents='Home'").Select()
C#
browserWindow.DomLink("@textContents='Home'").Select();
To find an object that has no real attributes for identification, use the index. For instance, to select the second hyperlink on a Web page, you can type:
VB
browserWindow.DomLink("[2]").Select()
C#
browserWindow.DomLink("[2]").Select();
Additionally, to find the first object of its kind, which might be useful if the object has no real attributes, you can type:
VB
browserWindow.DomLink().Select()
C#
browserWindow.DomLink().Select();