Error using link

0 views
Skip to first unread message

cw

unread,
Nov 18, 2009, 11:53:41 PM11/18/09
to iTest2
Hi Zhimin,

I'm still getting an error when using

link(:text => "Flagstaff Nordic Center case study", :index => 2).click

Any suggestions?

Thanks, C.

Here's the error:



1)
Watir::Exception::UnknownObjectException in 'Weather Bill Learn Tab
Learn / Case Studies Page'
Unable to locate element, using {:index=>2, :text=>"Flagstaff Nordic
Center case study"}
C:/cwong/itest2/New Folder/test_weatherbill/WBLearn_test.rb:43
C:/Program Files/iTest2/lib/itest2/rspec/rspec_executor.rb:129:in
`run_spec_via_druby'
C:/Program Files/iTest2/lib/itest2/rspec/rspec_executor.rb:66:in
`invoke_rspec'
C:/Program Files/iTest2/lib/itest2/rspec/rspec_executor.rb:57:in
`initialize'
C:/Program Files/iTest2/lib/itest2/rspec/rspec_executor.rb:57:in `new'
C:/Program Files/iTest2/lib/itest2/rspec/rspec_executor.rb:57:in
`invoke_rspec'
C:/Program Files/iTest2/lib/itest2/controllers/
main_frame_controller.rb:502:in `run_spec'
C:/Program Files/iTest2/lib/itest2/controllers/
main_frame_controller.rb:463:in `on_run_spec_on_line'
C:/Program Files/iTest2/lib/itest2/views/main_frame.rb:1513:in
`on_tool_click'
C:/Program Files/iTest2/lib/itest2/views/main_frame.rb:658:in
`setup_toolbar_events'
lib/iTest2.rb:225:in `call'
lib/iTest2.rb:225:in `process_event'
lib/iTest2.rb:225:in `on_run'
lib/iTest2.rb:225:in `main_loop'
lib/iTest2.rb:225:
Finished in 7.645 seconds
1 example, 1 failure

Zhimin

unread,
Nov 19, 2009, 12:38:59 AM11/19/09
to iTest2

> link(:text => "Flagstaff Nordic Center case study", :index => 2).click
> Unable to locate element, using {:index=>2, :text=>"Flagstaff Nordic
> Center case study"}

The test scripts looks fine to me. Can you post a fragment of HTML
source for those links.

Anyway, Here is test script demostrating clicking 2nd href links with
same text.

spec "General Demo" do
include RWebSpec::RSpecHelper

before(:all) do
open_browser("http://itest2.com/demo")
end

before(:each) do
goto_page("/demo")
end

scenario "Page has links with same text" do
click_link("Customer Interview")
# there are 3 links with 'Show Answer', click second one
browser.link(:text => "Show Answer", :index => 2).click
assert_visible(:div, "answer2")
end

end

Zhimin

unread,
Nov 19, 2009, 12:51:00 AM11/19/09
to iTest2
Sorry, I just saw your attached scripts.

Actually, there is only one link with text 'Flagstaff Nordic Center
case study'
<a href="assets/LandingPageDocs/flagstaff-case-study.pdf"
target="_blank" title="Flagstaff Nordic Center case study">Case Study</
a>

There are two links with title 'Bell Harbor Car Wash Case Study', and
this worked

link(:title => "Bell Harbor Car Wash Case Study", :index =>
2).click

Zhimin

cw

unread,
Nov 19, 2009, 8:38:49 AM11/19/09
to iTest2
Hi Zhimin,

I see my error. Thanks for pointing me to the demo page which helped
me figured out what I was doing wrong.

C.
Reply all
Reply to author
Forward
0 new messages