Element Locator

Element locator is a string used to identify an element or a group of elements on the web applications. It is required by most of mScript functions that interacts with UI applications like web applications. For example $click('id=submitBtn') clicks on the button that is identified with id=submitBtn.

Web Element Locator

There are several ways to specify the locator as described in plugin mScript functions. For web application you can identify the elements by:

  • id: id attribute assigned to the element. id is the preferred way to identify the elements as it is least impacted by the changes compare with other forms of locator. For example an element with id may be moved around in the web page. As long as the id is not changed, the mScript will continue to work.
  • name: name attribute assigned to the element, multiple elements may be shared the same name
  • xpath: xpath. xpath is very flexible and powerful in identifying any elements on the web page. There are tools you can use to automatically generate the xpath locator string, like Xpather or Xpath Checker. For more information about xpath, check out this xpath tutorial. Keep in mind that “xpath” may need to be adjusted when the element is moved around on the web page.
  • css: css style, e.g. #userID, .class1.
Print/export
QR Code
QR Code how_to_determine_locator_for_an_element (generated for current page)