appium_lib and Sauce

I had this working a long time ago, but now for the life of my I can’t figure out what’s wrong.

Currently desired caps are set:

caps: {
  'appium-version' => '1.3.7',
  platformName: 'iOS',
  platformVersion: '8.1',
  deviceName: 'iPhone Simulator',
  app: 'sauce-storage:whiteout_new.zip',
  name: 'test'
}

Both SAUCE_USER_NAME and SAUCE_ACCESS_KEY are set.

The driver is instantiated:

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

However, the test continually attempts to execute locally instead of against Sauce’s Selenium Grid. Based on the docs I can find I’m not sure what’s missing. I’m under the impression that if the two SAUCE variables are set then the Appium driver will set the remote URL, but that doesn’t seem to be working.

It must be SAUCE_USERNAME not SAUCE_USER_NAME

Also checkout this new article on appium_lib + Sauce.

Does the system env variable actually have to be set or can I set dynamically?

# Driver capabilities
SAUCE_USERNAME   = ENV["SAUCE_USERNAME"   ] || WD_CONFIG['username'  ]
SAUCE_ACCESS_KEY = ENV["SAUCE_ACCESS_KEY" ] || WD_CONFIG['access_key']

Basically I have the framework setup to take a command line arg, which determines which part of a yaml file to pull config details from, in this case it would be pulling sauce credentials.

REMOTE            = ENV['REMOTE'     ] || 'local'
...
WD_CONFIG  = YAML::load_file(File.join(__dir__, 'remote_config.yml'))[REMOTE]

Also, from browsing that article, is appium_ilb moving away from loading capabilities via text file?

You can set the sauce credentials in 3 ways:

opts = { 
  caps: {...},
  appium_lib: {
    sauce_username: 'blah',
    sauce_access_key: 'blah' }
};

If you’re loading from a file, that’s the entire point of appium.txt. All caps and options are supported via appium.txt. If you’d like dynamic then it’s fine to set the options hash via Ruby code. The ENV is mostly for Jenkins and other CI where it’s easier to use ENV. appium_lib will continue to support all 3 methods and there are no plans to move away from any of them.

Okay cool. I’ve left the majority of caps in the appium.txt because I believe that let’s arc do it’s magic, which is incredibly useful. If I’m executing on Sauce then I set the additional caps before starting the driver. All worked as expected.

Thanks.