I have the following step definitions with Page Object Pattern gem 'site_prism':
class Main < SitePrism::Page
element :login_link, "a.log-in-link"
element :login_field, "input[name='userLogin']"
element :pass_field, "input[name='userPassword']"
element :enter_button, ".button_pretty"
end
If /I'm log in as "([^"]*)" with password "([^"]*)"$/ do |login, pass|
@main = Main.new
@main.login_link.click
@main.login_field.set login
@main.pass_field.set pass
@main.enter_button.click
end
It works fine but looks very heavy and unbeautiful. Is there any way to write it like capybara 'within' method? The following isn't work (Error: "can't convert Main into String (TypeError)")
within @main do
login_link.click
login_field.set login
pass_field.set pass
enter_button.click
end
No, you can't use capybara's within
functionality with site_prism.