1

When I use click_no_wait function as shown below,

begin
  $browser.buttons[1].click_no_wait
rescue =>e
  puts e.message
end

It throws this following error

"undefined method `join' for nil:NilClass"

Can anyone please guide me why this error happens and How could I resolve this problem?

BroiSatse
  • 44,031
  • 8
  • 61
  • 86
RAJ
  • 898
  • 7
  • 16
  • 1
    Remove the begin-rescue-end to output the whole error, then add it to your question. – Rogue_Leader Sep 29 '14 at 11:48
  • 1
    please write the value of `button` variable. – Sachin Singh Sep 29 '14 at 11:50
  • Most likely your `buttons` does not contain two elements. If you want the first element, keep in mind theat indexes are 0 based. – BroiSatse Sep 29 '14 at 11:53
  • @Rogue_Leader, What is the difference, both are one,isn't it? – RAJ Sep 29 '14 at 12:48
  • 1
    @SachinSingh It's not exactly button, so value is not here, but I accomplish through '$browser.button(:class,'GoButton').click_no_wait', it's working fine now ,thanks. – RAJ Sep 29 '14 at 12:49
  • @BroiSatse Thanks for you comment, but I am aware of the fact that it's starts from index 0, and problem was not that, because I couldn't click that element using the above code, but I couldn't use click_no_wait methods on that. however I achieved through '$browser.button(:class,'GoButton').click_no_wait' – RAJ Sep 29 '14 at 12:50
  • No, the code you've given will only return the error name, not the stack trace, which is vital iun order to pin down exactly where the error is thrown. In any case, this is not a stable way to locate elements. You should use an ID -- $browser.button(id: 'my_login_button').click_no_wait -- or at least a class name -- $browser.buttons(class: 'default-submit-button')[1].click_no_wait -- if possible – Rogue_Leader Sep 29 '14 at 13:24
  • 1
    @Rogue_Leader Ok, Understood, I usually do that, But since I was interested to know the error I printed like that, I solved problem already as you mentioned. '$browser.button(:class,'GoButton').click_no_wait'. Thank you. – RAJ Sep 29 '14 at 13:39

1 Answers1

1

Ruby 1.9.3/ IE 9 - I had a click_no_wait error. Watir would not trigger a click on the Save button, which had to be followed by a click on a java popup 'OK' button that confirmed that the save button had saved the document correctly.

Using these two lines in place of the click_no_wait command gets the code working perfectly:

element.focus 
element.send_keys :return

Thanks DVG. My code -

ie.button(:id, 'MainContent_B_Save').focus
ie.button(:id, 'MainContent_B_Save').send_keys :return 
ie. javascript_dialog.button('OK').click

Check this : How to not wait for something with Watir-Webdriver

Community
  • 1
  • 1
RK . N
  • 308
  • 1
  • 2
  • 9