Shamoon
Shamoon

Reputation: 43491

How can I check to see if several elements are displayed with protractor?

  it('should show archived row profiles', function() {
    $$('.custom-control-input').get(0).click()
    $$('tr.archived')
    .then(function(elements) {
      console.log(elements);
    })
  })

But now how can I check to see if the elements are displayed?

Upvotes: 2

Views: 82

Answers (2)

Sudharsan Selvaraj
Sudharsan Selvaraj

Reputation: 4832

You can also use below piece of code,

var isElementsDisplayed = $$('tr.archived').isDisplayed();
expect(isElementsDisplayed).not.toContain(false);

isDisplayed() method will return array of boolean values(true/false) based on element display status. you can make a expect statement to check if the result array should not contain value false which means that particular element is not displayed.

Upvotes: 3

Mark
Mark

Reputation: 91

You can use isDisplayed.

$$('tr.archived').each(function(element, index) {
    console.log(element);
    expect(element.isDisplayed()).toBe(true);
});

Upvotes: 1

Related Questions