Getting a Selenium::WebDriver::Error::InvalidSessionIdError

I have been running my Android mobile automation fine for a couple years using Appium Desktop v1.14.0, Ruby on Rails and Cucumber without updating any versions because I know its fragile and I don’t want to spend time fixing everything once I upgrade to newer versions. I ended up running brew upgrade rbenv ruby-build and it upgraded my rbenv and ruby-build and now my automation has been failing. In my trouble shooting, I upgraded Appium to v1.21.0 and continue to get the same error I was seeing in v1.14.0. I am using rbenv 2.6.3 and `rbenv install’ support: /usr/local/bin/rbenv-install (ruby-build 20220125)


  • Appium version (or git revision) that exhibits the issue: Desktop v1.21.0
  • Last Appium version that did not exhibit the issue (if applicable): v.1.14.0 Desktop
  • Desktop OS/version used to run Appium: mac OS Big Sur v11.6.1
  • Node.js version (unless using|exe): 12.8.1
  • Npm or Yarn package manager: Homebrew
  • Mobile platform/version under test: Android 11
  • Real device or emulator/simulator: Real Device Samsung Galaxy S10+
  • Appium CLI or|exe:

I’m not even sure what part of Code to put in here, but I think the issue is with my mobile driver? And this is how I have it setup in the code:

def initialize_mobile_driver
  $driver = nil

  caps = get_capabilities

  $driver =, true)


def driver_quit