I am running some cucumber features using capybara and I need to check if a certain image is being shown.
I tried this xpath match but apparently the function matches
is not available:
//img[matches(@src, "my_image.png")]
I am running some cucumber features using capybara and I need to check if a certain image is being shown.
I tried this xpath match but apparently the function matches
is not available:
//img[matches(@src, "my_image.png")]
You don't need any
matches
function. Use:Or, if the path can include text before the portion you want to match:
This second expression imitates an
ends-with
function.If you don't like hard-coding the substring length, then use:
For completeness: in some cases, the following is acceptable: