Reputation: 919
In cases when we have a dynamic content population in a span tag, for e.g.,
.detail
%label Sku:
%span.#sku.detail= @deal.sku
When the deal in the above example doesn't have sku associated, the span element in the html will be as below without any content in it.
<div class="detail">
<label>Sku:</label>
<span id="sku" class="detail"></span>
</div>
If the SitePrism element is defined to look for this for e.g.,
element :sku, "#sku"
and if "@sample_page" is reference to my Site Prism page, and I refer sku as
@sample_page.sku.text
we will get Capybara::ElementNotFound Exception
Upvotes: 0
Views: 174
Reputation: 3266
When the span has no content it is not visible and thus not found. If you still want to find it, change your element to something like:
element :sku, "#sku", visible: false
Upvotes: 0
Reputation: 919
To avoid this we can check as below
@sample_page.has_sku?
and if the element is available then proceed with the actions as required.
This will omit Capybara::ElementNotFound Exception
Upvotes: 0