These are chat archives for cucumber/cucumber-ruby

Aug 2016
Jon Seidel
Aug 09 2016 00:10

@blueice349 I think the problem is with this statement:

  button_element = getButtonElementByValue( value )
    click( 'id', button_element.attribute( 'for' ) )

The getButtonElementByValue method returns an element which you just need to click...

  button_element = getButtonElementByValue( value )

Try that and see what you think; the error message indicates that it's the "id" selection...

It would also be helpful to include an HTML snippet so we can see what's actually on the page
Aug 09 2016 00:34
You are correct thanks
Aug 09 2016 02:41
Can someone tell me the best way to click on the View in this
Screen Shot 2016-08-08 at 8.40.36 PM.png
I would like to create a custom step, that all they need to do is type
And I click "View"
Also is there any tools that make it easy for getting elements on a page vs the inspect?

So the buttons that are set up the same would be View, Edit Delete

I started to create my custom step, but think I messed the xpath up so its not working

def getButtonElementByText( text )

   return $driver.find_element( :xpath, '//label[translate(normalize-space(text()),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")="' + text + '"]' )
Then(/^I click "(View|Edit|Delete|)"$/) do |text|

  button_element = getButtonElementByText( text )
Charan Damisetti
Aug 09 2016 05:26
@blueice349 with capybara try find(:xpath, './/a[text()="View"]')
Aug 09 2016 14:59
@dcharan that didn't work
Then I click "Edit" # features/step_definitions/forms.rb:50
no such element: Unable to locate element: {"method":"xpath","selector":"//a[text()="Edit"]"}
(Session info: chrome=52.0.2743.116)
(Driver info: chromedriver=2.23.409710 (0c4084804897ac45b5ff65a690ec6583b97225c0),platform=Mac OS X 10.11.5 x86_64) (Selenium::WebDriver::Error::NoSuchElementError)
./features/step_definitions/forms.rb:15:in getButtonElementByText' ./features/step_definitions/forms.rb:52:in/^I click "(View|Edit|Delete|Revisions|Text Messaging|NFC|)"$/'
features/automation_test/user_management/user_permissions/account_settings/users_tab/permissions_changeOwnUsername.feature:15:in `Then I click "Edit"'
tried with the .//a and with out the .//
Jon Seidel
Aug 09 2016 15:33
@blueice349 For "getting elements on a page", try the ruby PageObjectModule gem by Cheezy - You define all the elements and the code (css, xpath, ...) to locate them, and then reference them anywhere in your code with the name you define there.
Highly recommended...
@blueice349 For the suggestion by @dcharan , he suggested '//a[text()="View"]' but your error shows [text()="Edit"]. Also, I believe that the leading period (.) is not required... just the bare // for starters (that says 'any element' in XPath-speak).
Aug 09 2016 17:32
That does not work I tried both ways
Also I wanna look into your method using cheezy
Jon Seidel
Aug 09 2016 17:34
OK; I'll do a little testing when I get a few minutes..
Aug 09 2016 17:36
Thank you. The cheezy seems pretty complex at first look, would you have a simple sample to look at on that?
Jon Seidel
Aug 09 2016 18:19
Yeah; will have to wait for later, though... It's a very complex gem with lots of functionality, but there's a simple take on it. So I'll see what i can do for a basic example.
But it's really great for collecting all the "page" information / selection criteria into a single place so that you code once & reuse
We even put all 'click' events into our page modules so that if we have to add waits or make changes, it happens in one place.
Aug 09 2016 18:48
do you know why this would fail?
Then I should see page title as '"Access Denied | Template | ' + $default_account '"'
Jon Seidel
Aug 09 2016 18:50
What's the error message? Then what's the HTML?
Yeah... missing a '+' at the end before the '"'
 '"Access Denied | Template | ' + $default_account '"'
SyntaxError: (irb):2: syntax error, unexpected tSTRING_BEG, expecting end-of-input
 '"Access Denied | Template | ' + $default_account '"'
Aug 09 2016 18:53
sorry forgot to add that, still errors let me shorting the test and run it right now its doing 415 steps
  | page                                   |
  | "admin/config/system/cron"             |
  | "admin/config/system/cron/status"      |
  | "admin/config/system/cron/settings"    |
  | "admin/config/system/cron/maintenance" |

5 scenarios (4 undefined, 1 passed)
9 steps (4 undefined, 5 passed)

You can implement step definitions for undefined steps with these snippets:

Then(/^I should see page title as '"([^"]*)"'$/) do |arg1|
pending # Write code here that turns the phrase above into concrete actions

Jon Seidel
Aug 09 2016 19:48
It's getting confused over the number of single/double-quotes :=) And when it sees double-quotes, it assumes that's going to be an argument that you supply
I'd rewrite it as "Then I should see page title as default_account" and then in the step, put all that testing of possible values with an expect(...) statement