How do I write a cypress visible assertion for an element whose parent has css property hidden? I have the following HTMl code
<td class="item-total item-total-mobile-hidden">
<p class="mobile-show block-price-text">Total Price:</p>
<span class="price-total">
$699.99
</span>
</td>
When I write the following cypress code to assert that the price element is visible
Cy.get('.price-total').should('be.visible')
I get this error message Timed out retrying: expected '<span.price-total>' to be 'visible'
This element <span.price-total> is not visible because its parent <div.item-total-price-mobile-show> has CSS property: display: none
I have to tried to debug this on the console (putting the span in a variable $0)
$0
<span class="price-total"> $699.99 > Cypress.dom.isVisible($0) true
Here is shows the span element is isVisible true, but I am unable to assert it. I tried the following by invoking the text on the child element, but it didn't work either
cy.get('.price-total').invoke('text')
.then((text)=>{
const divTxt = text;
expect(divTxt).to.be.visible; })
This did not work, I get the following error because cypress couln't find the hidden element Timed out retrying: Expected to find element: .price-total, but never found it.
What's the best way to assert that the element <span class="price-total"> is visible?