xpath - Href link click using capybara -


how can click link using capybara.i need click graduation link

<a href="/arts?occasion=graduation&amp;top_menu_item_title=+-+graduation">graduation</a> 

i used following code .but showing error message undefined method click

 page.find(:link,"graduation").click 

also used xpath

page.find(:xpath, "//a[@href='/arts?occasion=graduation']").click 

it not working

but problem page contains multiple links of graduation.

so using page.all(:link,"graduation") returns ambiguous match, found 2 elements matching link "graduation"

page.all(:link,"graduation") returns ambiguous match, found 2 elements matching link "graduation" 

that means page contains multiple graduation text link.so if want click first 1 can write

  page.all(:link,"graduation")[0].click 

it click first link , below 1 click second link.you can use needs.

  page.all(:link,"graduation")[1].click 

am sure work you


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -