paulotarcio
paulotarcio

Reputation: 499

How to verify if an element with a class appears using protractor

I need to verify with this div appears, but it's not working. I'm trying to use by classeName.

<div aria-live="polite" class="ui-growl-item-container ui-state-highlight ui-corner-all ui-shadow ui-growl-message-sucess">

My Code:

const validacao =  element(by.className('.ui-growl-item-container.ui-state-highlight.ui-corner-all.ui-shadow.ui-growl-message-sucess'));

expect (validacao.isPresente()).ToBeTruthy();

Protactor keeps returning me false. Why?

Upvotes: 0

Views: 89

Answers (1)

Andersson
Andersson

Reputation: 52665

Actually you're passing CSS selector, but not class name.

To make it work as expected, try

const validacao =  element(by.css('.ui-growl-item-container.ui-state-highlight.ui-corner-all.ui-shadow.ui-growl-message-sucess'));

or

const validacao =  $('.ui-growl-item-container.ui-state-highlight.ui-corner-all.ui-shadow.ui-growl-message-sucess');

or you can pass single class name to by.className() as

const validacao =  element(by.className('ui-growl-item-container'));

Upvotes: 1

Related Questions