this kind of test honestly confuses me I understand you want to check to see if the link exists so why not do that instead of calling a method to check to see if it exists and then checking to see if that method returns true
I dont use page_object but I think this is the right syntax (on(LoginPage).signout).should exist but i think be present makes more sense because it can exist and not be visible which would still pass in the above test (on(LoginPage).signout).should be_present On Fri, Nov 2, 2012 at 12:18 AM, Barry Horgan <[email protected]> wrote: > Hi, > > I can't figure this out. I am trying to verify a links exists on a page, > after user logs in, using .exists? method. It works when I > use @browser.link(:text => "Sign Out") . to define the element but i want > define link using PageObjedt gem using link(:signout, :text => 'Sign Out') > > Any ideas as to why this should happen? > > Thanks, > > Barry. > > ERROR: > Scenario: Registered user logs in to account > And a user exists > When I enter my login details > Then I should have access to my account > undefined method `exists?' for []:Array (NoMethodError) > ./features/step_definitions/login_page.rb:18:in > `sign_out_link_exists' > ./features/step_definitions/login_steps.rb:14:in `/^I should have > access to my account$/' > features/login.feature:14:in `Then I should have access to my > account' > > > > CLASS FILE: > > class LoginPage > include PageObject > include DataMagic > > text_field(:email, :id => 'email') > text_field(:password, :id => 'password') > button(:signin, :id => 'loginBtn') > link(:signout, :text => 'Sign Out') > > page_url "#{ENV['BaseUrl']}/user/signin" > > def login(data = {}) > populate_page_with data_for(:login_page, data) > signin > end > > def sign_out_link_exists > signout.exists? > #@browser.link(:text => "Sign Out").exists? > end > end > > > STEP DEF: > Then /^I should have access to my account$/ do > (on(LoginPage).sign_out_link_exists).should be_true > end > > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > [email protected] > http://groups.google.com/group/watir-general > [email protected] > -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
