Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor - get child element of an element?

Tags:

People also ask

What is element all in protractor?

element. all(locator). all(locator) View code Calls to ElementArrayFinder may be chained to find an array of elements using the current elements in this ElementArrayFinder as the starting point. This function returns a new ElementArrayFinder which would contain the children elements found (and could also be empty).


I am trying to access child element of an ng-repeat element but I am having troubles doing that.

I have searched around about the problem and the solutions that I have found did not work for me. One of those solutions was to do something like this:

var parent = element(by.repeater(''));
var child = parent.element(by.....);

When I try the child line I cant see the element function on the parent element..

http://prikachi.com/images/11/8338011u.png

If you see the screenshot above you will see the structure of the code of the page that I am trying to test.

I need to access the alt attribute of the image of the avatar and get its value (thats the Username of the User).

One thing that came to my mind is to use .getInnerHTML() on the ng-repeat row which will return a string with all that code. From there I can find the alt attribute and its value with string manipulation but this seems too brute and I am sure that there has to be a better way.

Simply I want to be able to get row 4 from the repeater and get the Username of the user at row 4, that's all I wanna do actually.