Help setting up Mobile Web Android using Ruby

I have successfully setup appium for native app and looking for some help setting up appium for android mobile web testing using Ruby language.

Anyone have any examples or help me the configuration capabilities for android mobile web and rspec configuration or cucumber support/env.rb?

Receiving the following exception:
Could not determine your device from Appium arguments or desired capabilities. Please make sure to specify the ‘deviceName’ and ‘platformName’ capabilities

I have referenced the appium documentation to fill out the capabilities -


    platformName = "android"
    deviceName =  "Samsung"
    platformVersion =  "4.4"
    orientation = "PORTRAIT"
    browserName: "Chrome"
    appPackage = ""
    appActivity = ""


require 'rubygems'
require 'rspec/expectations'
require 'appium_lib'
require 'selenium-webdriver'
require 'pry'

caps = Appium.load_appium_txt file: File.join(Dir.pwd, 'appium.txt')

appium_url = 'http://localhost:4723/wd/hub'

Before {
  @driver = Selenium::WebDriver.for(:remote, :url => appium_url, :desired_capabilities => caps)

After {

Any assistances would be appreciated,

Create AppiumDriver instead of WebDriver:

@driver =

where capabilities are:

capabilities = {caps:
                        :deviceName => $device_name,
                        :browserName => 'Chrome',
                        :appPackage => '',
                        :platformName => 'Android',
                        :udid => ANDROID_UDID,

kirill - this helped and now trying understand this error message

error: Failed to start an Appium session, err was: Error: Device MY_ANDROID_UDID was not in the list of connected devices

Is there an appium configuration file where I need list all my devices?


Make sure device is connected, USB debugging is on, and adb devices returns your device udid.
Basically, do adb devices in the command line and tell me what you get.

Thanks @kirill for the help. I finally got my device connected via USB and WiFi able to run appium mobile web tests using the chrome driver. I seriously need to improve the support/env.rb, but I was able to get it working.

require 'rspec/expectations'
require 'appium_lib'
require 'selenium-webdriver'
require 'timeout'

# Default URL
$mobileweb_url = ''

CAPS = {
    'browserName' => 'Chrome',
    'platformName' => 'Android',
    'deviceName' => 'Samsung',
    'platformVersion' => '4.4',

def server_url

def driver
  @driver ||= CAPS)

def appium_driver
  driver #in case if still not initialized

def base_url(path)
  $mobileweb_url + path

Before do

After do

That’s great, that you got it working!
You can put the hooks in separate file called hooks.rb in the same repository with env.rb :slight_smile:

I also have similar problem. While searching on Google for the solution I come across this discussion.

In my case I have to test that app picks up the system language. So first I have to test FR, then RU and so on with 10-12 different locales.

How can I do that?

One thing that I can think of is to create 1 separate test file for each test and then run them in parallel. For each file I will put caps in Before function and quit driver in after function. These Before/After functions are test specific not global.

Now issue is I don’t know how to set caps in before function.