I have a page with several links like that <a href='/bla/bla/bla/?page=xxx>text</a>
I want to match certains xxx
values links using Capybara and RSpec, i don't care about bla/bla/bla
part of href
attribute.
page.should have_selector("div.class ul li a", :href => "page=2")
doesn't work, also
page.should have_xpath("//a[@href='page=2']")
is not an option because i don't know the full href
attribute value.
PS: also didn't find any complete Capybara API documentation just to get all available methods and parameters' description. I there such thing?
Try using contains
:
page.should have_xpath "//a[contains(@href,'page=2')]"
Try this:
link = page.find('div.class ul li a')
link[:href].should match(/page=2/)
More information here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With