I have a div like this:
<div class="class1 class2 class3" ng-click="displayItems(category.categoryId, category.categoryDescription, category.associatedToElements, 'isItemChecked')"> </div>
When I am trying to get the element in Protractor by css:
var elementList = element.all(by.css('class2'));
I am getting undefined.
When I am trying the same with ng-click:
var elementList = element.all(by.css('[ng-click="displayItems(category.categoryId, category.categoryDescription, category.associatedToElements, "isItemChecked")"]'))
still I am unable to track any element.
Suggestions are most welcome.
This is my code:
var categoryList, firstCategory;
beforeEach(function(){
categoryList = element.all(by.css('.class2'));
firstCategory = categoryList.last();
});
it('Should display values correctly', function(){
firstCategory.click();
});
If you are learning how to use protractor I would suggest you to try elementor. It will suggest selectors based on the currently selected item.
You can do this:
$('.class1.class2.class3')
It is the same as:
element(by.css('.class1.class2.class3'))
Try replace class2
to .class2
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With