ruby on rails - Unable to locate element with cucumber step_definition, but able to locate it with capybara stand-alone -


i testing website has both vertical login form on right, , horizontal form on bottom. both have identically named "email" , "password" fields. employing capybara's within scope fields i'm interested in. interesting bits of web form this:

enter image description here

i have 2 separate projects, in experimenting sauce labs automation. first project capybara-only example, modified test page shown above. second project cucumber implementation of exact same tests. these simple, one-time hard-coded tests, proof of concept of 2 techniques.

here interesting bit of capybara-only example:

within(:css, ".right-container.login-form")     fill_in 'email', :with => "greg.gauthier+#{generate_email_suffix}@website.com"     fill_in 'password', :with => 'l33tp@$$w0rd'     click_button 'submit' end 

here interesting bit of cucumber step_definition:

when(/^the user enters information$/)     within(:css, ".right-container.login-form") #the page has duplicate forms         fill_in 'email', :with => "greg.gauthier+#{generate_email_suffix}@website.com"         fill_in 'password', :with => 'l33tp@$$w0rd'         click_button 'submit'     end end 

when run capybara-only version, works great. form gets filled in, , email confirmation gets sent.

however, when run cucumber version, error:

unable find css ".right-container.login-form" (capybara::elementnotfound) 

how can be? it's exact same page, exact same capybara method (within, using :css selector), , exact same test code. not getting (aside fact i'm cuking wrong)?

oh, here's require list looks in sauce_helper:

capybara-only version:

require "sauce" require "sauce/capybara" require 'capybara/rails' require 'capybara/rspec' 

cucumber version:

require "sauce" require "sauce/capybara" require "sauce/cucumber" 

do maybe need include capybara gems in cucumber version?

ok, i'm embarrassed admit this, reason question ignorance of webdriver behavior, @ least works capybara/cucumber.

the test in question second scenario in set of scenarios. apparently, selenium resets browser blank, between each scenario. so, test 1 works perfectly, test two, three, , forth fail on elementnotfound because, of course... page in question not loaded.

i added before hook hooks.rb file in support path, , it's working.

apologies cluttering question stream...


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -