0

I need a way to check if an element has children.

    <div class="purchaseRoMPixels">
       <img style="display:none" src="//api.com;value=20">
       <noscript>&lt;img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com" /&gt;</noscript>
    </div>

I tried the following but they dont work

find(".purchaseRomPixels").children.length.should > 0

This also does not correctly test what I am trying to test

find(".purchaseRoMPixels").text.should == ""

It will always return true, because there is no text in that div. But I want it to return true only if those elements exist in the div.

user2158382
  • 4,430
  • 12
  • 55
  • 97

1 Answers1

0

Try with:

expect(find(:css, '.purchaseRoMPixels').text).to_not be_empty

I think you messed up in this line of your examples:

find(".purchaseRoMPixels").text.should == ""

and wanted to use a not equals rather than an equals operator, I mean:

find(".purchaseRoMPixels").text.should != ""
carpamon
  • 6,515
  • 3
  • 38
  • 51