ruby on rails - How can I get Title & href (URL)? -
i have following html code. want href & title of product & store them different variables. have tried following code.
within("div.product-action") @product_url = find("a.href") end but throws error.
capybara::elementnotfound: unable find css "a.href" my html code follow:
<div class="product-action zoom" ng-class="{ 'logged-out': !user.$isloggedin }"> <a href="/g/women/christian-dior/so-real-sunglasses-colorless" title="christian dior real" sunglasses-colorless" ng-click="productutils.cache(result)" class="bottom-action-container quickview-button hover-option" track="{ type: 'product-info', name: moduletype, breadcrumbs: result.breadcrumbs || breadcrumbs }"> <i class="icon-zoom"></i> </a> </div>
a.href select a elements have href class. not want.
you can access attributes hash after found element:
a = find('.product-action a') href = a[:href] title = a[:title]
Comments
Post a Comment