0

I have been running into a strange gremlin of sorts in my code as of late. Randomly it will dump a "stack level too deep (SystemStackError)" error on a piece of code that has previous, sometimes moments before, been working. I have read through the similar threads here at SO involving stack level, but cannot seem to find my problem. There is a recursion happening somewhere but it doesn't seem to be consistent.

The the two most common error points:

stack level too deep (SystemStackError)
      ./features/step_definitions/login.rb:40:in `/^I enter username "([^"]*)"$/'
      features/01_login.feature:30:in `When I enter username "John"'



stack level too deep (SystemStackError)
      ./features/step_definitions/login.rb:23:in `/^I press select env$/'
      features/01_login.feature:26:in `Then I press select env'

Running my test the first error would pop up with the username, having only moments before completed this test successfully. Running my test again after a reset would bring up the second error which is even more bizarre since the test needs to run THROUGH this point to even get to the username which we reached in the first run. This order is not consistent. Sometimes it will just error out over one or another piece making it difficult to track down.

The code for the the two errors in question.

When (/^I enter username "([^"]*)"$/) do | username |
        enter_text "UITextFieldLabel text:'Username'", "John"
    end

Then (/^I press select env$/) do
        touch "label text:'Select Env'"
    end
CMESSEY
  • 17
  • 2

1 Answers1

0

There is a good chance that all you need is a wait before trying to use the elements in each case. I have run into similar issues where I was hitting some method_missings and getting stuck in a loop when I was trying to interact with elements that weren't there yet or weren't ready to be interacted with.

There are many wait methods in calabash but in this case you probably want wait_for_element_exists

http://calabashapi.xamarin.com/ios/Calabash/Cucumber/WaitHelpers.html#wait_for_element_exists-instance_method

alannichols
  • 1,496
  • 1
  • 10
  • 20
  • 1
    In my experience sometimes you need to use regular sleep because wait_for will fire before the elements are actually visible. It is not a nice solution but it can be helpful. – Lasse Jun 15 '15 at 10:35
  • In those cases I prefer to use a wait_for then a very short sleep rather than a long sleep, but you're right. I think it's to do with an element being visible but still in a state of screen transition when calabash finishes it's wait and it only happens sometimes in the apps I've tested. – alannichols Jun 15 '15 at 10:39
  • Thank you. I have started to use a combination of sleep and wait as suggested and it has eliminated the stack level issue. – CMESSEY Jun 17 '15 at 15:21