Edmond
Edmond

Reputation: 131

Protractor: Trying to check if an Element is not displayed on page ( using .count() )

I originally had this working but I've started using Gulp and Lint so now I need to change how I approach this. I'm checking to see if a user has a single currency displaying or multiple currencies. If a user only has one currency (e.g "EUR") then a div called "nav-tabs au-target" show.bind="positions.length > 1" au-target-id="37" will not be displayed on the page.

This is the code from page object file

if(text.indexOf("EUR") >-1 && text.indexOf("GBP") ===-1 && text.indexOf("USD") ===-1){
expect(element(by.css("nav-tabs au-target")).count()).toBe(0);}

Basically it's checking if"EUR" is only displayed then expect "div nav-tabs au-target" not to be present. When I run this code, I get the following error Failed: element(...).count is not a function Thanks for any help

Upvotes: 0

Views: 163

Answers (1)

alecxe
alecxe

Reputation: 473873

There is no .count() method on the ElementFinder instance (result of element()). count() is a method of an ElementArrayFinder instance (result of element.all()).

Note that if you would've used ESLint JavaScript linter with the eslint-plugin-protractor plugin (shameless self-promotion), you could've caught the problem earlier - during coding, without actually executing tests:

enter image description here

Upvotes: 1

Related Questions