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&quot; 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

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -