Concept of Chain Locators 


The essence of end-to-end website testing is finding DOM objects, dealing with them and getting details about the application’s current state. Protractor is one of the most commonly used frameworks for AngularJS applications where locators are used as instructions to show Protractor how to locate the element.

Finding the elements is not a significant challenge since there are many ways to do it, for example, by.css,,, by.model,etc.

Using a single locator to find:

– an element: element(by.css('.myclass’)); 

– a list of elements: element.all(by.css('.myclass’));

Considering that for some subelements of the website we are not always able to identify locators as mentioned above, we have to use the Concept of Chain Locators. This means that you can chain multiple locators to select an element in a complex application, such as:


Chain Locators to Identify Child Elements

This is an overview of a Protractor test in Jasmine, where we have an example of using a chain locator to reach a child element.

describe('Chain locators', function() {  
it('Open Angular js website',function() {
element(by.repeater("resultinmemory")).element(by.css("td:nth-child(3)")).getText().then(function(text) {


“Chaining locators in Protractor” Tech Bite was brought to you by Admira Suljić, Junior Test Engineer at Atlantbh.

Tech Bites are tips, tricks, snippets or explanations about various programming technologies and paradigms, which can help engineers with their everyday job.


Leave a Reply