Skip to content

Locators and Location Strategies

Before you read this you may want to see:

Locators and Location Strategies

A locator is a target that identifies an element in the content of the web application. Location strategy is identifying all the possible locator types of an element.

QaSCRIBE records all the possible locators of an element, which allows the user to view other possible locator-types arguments that could be used instead. This is a very useful feature that would allow you to switch between the locators. This also helps you to remove locator types that are dynamic.

This locator assistance is available when you create/edit a test script as a drop-down list accessible for each instruction at the Target field (only when the Target field contains a recorded locator-type).


QaSCRIBE has a default order of locators that get recorded. Custom sequence the way you want the locators to be recorded in the "My Project Settings".

Some of the Locator types are listed below.

  • Identifier
  • Id
  • Name
  • Xpath
  • Hyperlink
  • Dom
  • CSS

Below is the detailed explanation of each locator type

Locating by Identifier:

The identifier here would be the attributes of an element locator in the content of the web application. This is a common method to look up for an element with an id attribute if no element with id attribute is found then the first element with a name attribute matching the locator is used.

Locating by Id

This is used when you know the element's Id. Id's can be dynamic and is not always dependable. If you are sure that the id will not change then use the element's id attribute.

Locating by Name

The name locator type will locate the first element with a matching name attribute. If multiple elements have the same value for a name attribute, then you can use filters to further refine your location strategy. The default filter type is a value (matching the value attribute).

Locating by XPath

If your application is dynamic or if it does not have attributes with id's, name's, value etc to be constant and there are chances of the web content changes, in such scenarios to locate an element irrespective of the changes made we use XPath.

XPath is the language used for locating nodes in an XML document. Simple methods of locating by id or name attribute to a complex path of navigating to nth element in the web page is possible using XPath.

You can use XPath to either locate the element in absolute terms (not advised) or relative to an element that does have an id or name attribute. XPath locators can also be used to specify elements via attributes other than id and name.

Absolute XPaths contain the location of all elements from the root (HTML) and as a result are likely to fail with only the slightest adjustment to the application. By finding a nearby element with an id or name attribute (ideally a parent element) you can locate your target element based on the relationship. This is much less likely to change and can make your tests more robust.

Since only XPath locators start with “//”, it is not necessary to include the xpath= label when specifying an XPath locator.

Locating Hyperlinks by Link Text

This is a simple method of locating a hyperlink in your web page by using the text of the link. If two links with the same text are present, then the first match will be used.

Click here to know how to write custom/manual XPath

Locating by DOM

The Document Object Model represents an HTML document and can be accessed using JavaScript. This location strategy takes JavaScript that evaluates to an element on the page, which can be simply the element’s location using the hierarchical dotted notation.

Since only dom locators start with “document”, it is not necessary to include the dom= label when specifying a DOM locator.

Locating by CSS

CSS (Cascading Style Sheets) is a language for describing the rendering of HTML and XML documents. CSS uses Selectors for binding style properties to elements in the document. These Selectors can be used by QaSCRIBE as another locating strategy.


After you read this article you may want to see:

Feedback and Knowledge Base