user5186342
user5186342

Reputation:

protractor Unexpected identifier for selector

I was trying to select a element using protractor

<span data-ng-if="check.medium === 'AIR'" class="ng-scope">Clean air</span>

command I used to extract element is

$('span[data-ng-if="task.medium === 'AIR'"]')isDisplayed().toBe(true);

I was getting a failed expectation error, Im really not sure what could be the fault

Any help is much appricaiated. Thanks in advance

Upvotes: 2

Views: 294

Answers (1)

alecxe
alecxe

Reputation: 473833

You need to escape the single quotes inside the selector. And, you are missing the expect() call and a dot before the isDisplayed() call:

expect($('span[data-ng-if="task.medium === \'AIR\'"]').isDisplayed()).toBe(true);

I would though, if possible and applicable, rely on the element's text instead:

expect(element(by.xpath("//span[. = 'Clean air']").isDisplayed()).toBe(true);

Upvotes: 1

Related Questions