Object Type and Search Scope

A locator typically contains the type of object to identify and a search scope. The search scope is one of the following:
  • //
  • /

Locators rely on the current object, which is the object for which the locator is specified. The current object is located in the object hierarchy of the application's UI. All locators depend on the position of the current object in this hierarchy, much like a file system.

XPath expressions rely on the current context, which is the position of the object in the hierarchy on which the Find method was invoked. All XPath expressions depend on this position, much like a file system.

Note:

The object type in a locator for an HTML element is either the HTML tag name or the class name that Silk4NET uses for this object. For example, the locators //a and //DomLink, where DomLink is the name for hyperlinks in Silk4NET, are equivalent. For all non-HTML based technologies only the Silk4NET class name can be used.

Example

  • //a identifies hyperlink objects in any hierarchy relative to the current object.
  • /a identifies hyperlink objects that are direct children of the current object.
Note: <a> is the HTML tag for hyperlinks on a Web page.

Example

The following code sample identifies the first hyperlink in a browser. This example assumes that a variable with the name browserWindow exists in the script that refers to a running browser instance. Here the type is "a" and the current object is browserWindow.

VB

Dim link As DomLink = browserWindow.DomLink("//a")

C#

DomLink link = browserWindow.DomLink("//a");