appium_lib ruby set caps issue when not using Appium.txt

Hi everyone.

I have the the following in my appium.txt file:

[caps]
platformName = "iOS"
platformVersion = '9.2'
app = "blah.app"
deviceName = "iPhone 6"
sendKeyStrategy = "setValue"
autoWebview = "true"

when I use this to launch a test it works fine. But I want to make the tests more flexible and you cannot use names other than appium.txt for the caps file. So I am using the following:

caps = {
   'platformName' => 'iOS',
   'platformVersion' => '9.2',
   'app' => 'blah.app',
   'deviceName' => 'iPhone 6',
   'sendKeyStrategy' => 'setValue',
   'autoWebview' => 'true'
 }

$appium_driver = Appium::Driver.new(caps)

However when I try to run the tests this way I get the following error:

Selenium::WebDriver::Error::SessionNotCreatedError:
The following desired capabilities are required, but were not provided: platformName, deviceName

I am specifying those values in the hash so not understanding what’s happening here.

Hoping someone can help.

Sincerely,

I think you are missing the symbol caps:

So something like this:

caps = {
   'platformName' => 'iOS',
   'platformVersion' => '9.2',
   'app' => 'blah.app',
   'deviceName' => 'iPhone 6',
   'sendKeyStrategy' => 'setValue',
   'autoWebview' => 'true'
 }

$appium_driver = Appium::Driver.new(caps: caps)

Check out the initialize method for Driver here:

From the comments:

Start iOS driver

# opts = { caps: { platformName: :ios, app: '/path/to/MyiOS.app' } }
# Appium::Driver.new(opts).start_driver
#
# # Start Android driver
# opts = { caps: { platformName: :android, app: '/path/to/my.apk' } }
# Appium::Driver.new(opts).start_driver
# ```
1 Like

Hi wreed.

That was it. Thank you VERY MUCH!

Sincerely