Jasmine: how to write conditional statement based on check if element exists?

Hi everyone!

I’m writing a test using Jasmine framework with the following logic:

if ($(locator).isPresent == false) 
        //some actions to create this element
//do some actions with this element

If this element actually exists in application during the test, everything is ok.
If it doesn’t and the test must create it, if always fails, because element isn’t found by locator.

I tried :
$(locator).isPresent == false
$(locator).isDisplayed() == false

And as a result actions in {} never work. How to write this conditional statement correctly for both cases - if element exists and if it doesn’t?

Thanks a lot for any help!

(sorry if my description isn’t clear enough because I don’t speak English well).

1 Like

hi, did you find a solution for this,? how did you achieve it