I have a page-internal link in an html page:
<div class="bar">
<a href="#foo">Go to foo</a>
</div>
I selected this anchor element using Capybara matcher. When I try to access the href attribute, the value is expanded to full URL:
find(".bar a")[:href] # => "http://path/to/page#foo"
How can get only the internal link, i.e., the verbatim href value?
find(".bar a")... # => "#foo"
Capybara returns the property
href(as opposed to the attribute) in JS capable drivers, which is normalized. To get access to the attribute value you will need to use evaluate_scriptIf, on the other hand, you just want to verify the link has that specific href attribute you can do that with the :link selector
or to find the link by the href attribute
etc...