Discussion:
[wtr-general] Click Function yes/no?
o***@charterup.com
2018-01-11 16:18:22 UTC
Permalink
Is there a better way to create a function that just clicks what you need
it to click as opposed to having so many of this in your step definitions?
One for login, logout, add, etc.

Ex, Logout
Then(/^I logout the system$/) do
@browser.a(:href => '/logout').click
end
How or what is the best way to go about it.

Thanks.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2018-01-11 17:33:48 UTC
Permalink
The easy answer is don't use cucumber. :)
I've done a lot of cucumber, and in most circumstances where people
use it, they shouldn't be.

That being said, this is how I did my cucumber:

Feature file: English Sentences of preconditions actions and results;
Only business logic
Step file: Convert english sentence into the Page Object / Method /
Parameter calls
Page Object: Where all the implementation lies with element
definitions and actions.

Ex:

Given I am on the Home Page
When I logout

Given /^I am on the (\w)+ Page$/ do |page|
@page = page

When /^I (\w)+$/ do |action|
@page.new.send action

class Home
element :logout_link {@browser.a(href: '/logout) }
def logout
logout_link.click
end
end
Is there a better way to create a function that just clicks what you need it
to click as opposed to having so many of this in your step definitions? One
for login, logout, add, etc.
Ex, Logout
Then(/^I logout the system$/) do
@browser.a(:href => '/logout').click
end
How or what is the best way to go about it.
Thanks.
--
--
Before posting, please read
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...