random stack level too deep (SystemStackError)

224 views Asked by At

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
1

There are 1 answers

3
alannichols On BEST ANSWER

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