Question about buttons in classes

14 views
Skip to first unread message

mark lane

unread,
Nov 28, 2017, 3:50:05 PM11/28/17
to Cucumber and Cheese
In some of the book the buttons are added in the page Class e.g 
button(:add_to_cart, value: 'Adopt Me!')

There is no click event (.click) and the button is called from the steps with
@details.add_to_cart

How does the call know that I am clicking the button

When we did the same with a method in the Class the method contained the .click event e.g.
def select_puppy_number(num)
button_element(value: 'View Details', index: num - 1).click
end

This makes more sense as the method is called and the click event is instigated. How does it know though that we are clicking the button on the first Adopt Me button?









Carlos GZ

unread,
Nov 29, 2017, 3:45:38 AM11/29/17
to mark lane, Cucumber and Cheese
Hi Mark

It is built into the page object gem that unless you add _element to your element that it will automatically click that element. Each element itself has an inbuilt action which is described in the appendices towards the back of Jeff's book.

If you have any further questions feel free to email me.

Regards 

Carlos 

mark lane

unread,
Nov 29, 2017, 2:53:52 PM11/29/17
to Cucumber and Cheese
Thanks Carlos . Makes sense now!
Reply all
Reply to author
Forward
0 new messages