'Twilio with Capybara Getting "stack level too deep (SystemStackError)" error

I am getting stack level too deep (SystemStackError) error when trying to make Read: List messages matching filter criteria API call for Twilio in Selenium/Cucumber framework. I have no issues making this API call outside of Capybara framework as a pure Ruby code.

Here is my code:

@mfa_client = Twilio::REST::Client.new account_sid, auth_token
@mfa_client.messages.list(from: "+#{@sender_phone}", to: "+#{@recipient_phone}", limit: 1)

Error:

/.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/dsl.rb:46:in `page': stack level too deep (SystemStackError)
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/dsl.rb:52:in `query'
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/session.rb:771:in `query'
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/dsl.rb:52:in `call'
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/dsl.rb:52:in `query'
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/session.rb:771:in `query'
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/dsl.rb:52:in `call'
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/dsl.rb:52:in `query'
        from /.rvm/gems/ruby-3.0.0/gems/capybara-3.37.1/lib/capybara/session.rb:771:in `query'
         ... 10607 levels...
        from /.rvm/gems/ruby-3.0.0/bin/spinach:23:in `load'
        from /.rvm/gems/ruby-3.0.0/bin/spinach:23:in `<main>'
        from /.rvm/gems/ruby-3.0.0/bin/ruby_executable_hooks:24:in `eval'
        from /.rvm/gems/ruby-3.0.0/bin/ruby_executable_hooks:24:in `<main>'





Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source