Differences

This shows you the differences between two versions of the page.

Link to this comparison view

how_to_determine_locator_for_an_element [2016/09/22 02:35]
how_to_determine_locator_for_an_element [2016/09/22 02:35] (current)
Line 1: Line 1:
 +=====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 [[mScriptFunc|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 [[http://​testoptimal.com/​javaDoc/​reference/​com/​webmbt/​plugin/​SeleniumPlugin.html|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//: [[http://​www.w3.org/​TR/​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 [[https://​addons.mozilla.org/​en-US/​firefox/​addon/​1192/​|Xpather]] or [[https://​addons.mozilla.org/​en-US/​firefox/​addon/​1095/​|Xpath Checker]]. For more information about //xpath//, check out this [[http://​www.w3schools.com/​xpath/​default.asp|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)