I'm facing a challenge in my code where I need to ensure that the message "Product successfully added to your shopping cart" appears after adding an item to the cart. Here, there is no specific tag enclosing the text, making it tricky to target for verification.
https://i.sstatic.net/TSRog.png
The complete xpath for this text element is:
//*[@id="layer_cart"]/div[1]/div[1]/h2/text()
However, when attempting to use this full xpath, an error is thrown stating "object is text, it should be an element."
On the other hand, if I use the xpath until
"[@id="layer_cart"]/div[1]/div[1]/h2"
without including 'text()'
, the text cannot be extracted and verified because it's not enclosed within any tags. This results in blank text being returned. Any suggestions on how to tackle this issue? Thank you.