1

I have a problem while testing my cases on browser stack. The problem am facing is inconsistently reproduced.

To make my code wait until an element is loaded am using as below:

gift_no_btn1 = Capybara.find('giftingNoButton')
gift_no_btn1.click

The problem here is that the screen is stuck in the other module where my intended element is not loaded and hence my script fails. I have read that find() method is replaced of wait_untill method in Capybara 2.0.

orde
  • 5,154
  • 6
  • 29
  • 33
Pradeep
  • 35
  • 1
  • 5

1 Answers1

4

Capybaras find methods will wait up to Capybara.default_max_wait_time seconds for a matching element to appear. If they are not waiting long enough either increase that setting or override it for a specific find with the :wait option like

page.find :css, 'CSS selector for the element', wait: 10

which will wait up to 10 seconds for the element to exist. In your example you're passing a CSS selector of 'giftingNoButton' which isn't really valid unless you're using custom elements. You probably want '#giftingNoButton' (find id matching) or '.giftingNoButton' (class matching)

Thomas Walpole
  • 42,399
  • 5
  • 53
  • 67