I'm having problems with executing a script written in RubyGems for an android APK

I’m using selenium Webdriver and writing a script with Rubygems. I would like to test an app on a physical device. Unfortunately I’m receiving issue such as I’m missing platformName or other error messages regarding my desiredcapabilities.

My goal is to connect my phone to the computer and execute a script that will take the apk, initialize it on the device and run the script. I’m unable to get it to start. What am I missing or what do I need to add to my code so that I can initiate the app on my device?

Thanks for your help.

require 'rubygems'
require 'selenium-webdriver'
require 'uri'
require 'appium_lib'
require_relative 'SDK_Navigation'

mySampleApp = SampleApp.new

CAPS =  {
      'platformName' => "Android",
      'deviceName' => "HT44WSF07408"
    }
driver = Selenium::WebDriver.for(:remote, :url => "http://127.0.0.1:4723/wd/hub", :desiredCapabilies => CAPS)
mySampleApp.PickImagebtn(driver)

I wanted to make sure my problem was explained a little easier. I’m using rubygems and when my script is executed I want the app (apk is on my laptop) to startup on my physical device and the rest of the script to execute.

When I manually run the apk from appium the app will start on the phone. I’m just having problems understanding how to get the app to start on the phone with a script.

thanks

Hi @fegero:

So you are missing some capabilities (in your CAPS section).

appPackage
appActivity
appWaitActivity

Filling in the above should solve your problems. 2 options follow:

  1. You use some preprocessing logic (I use a Rake task) to install the apk before running your tests.
  2. If you add this capability
    app = “my.apk”

Appium should install your apk automatically if it does not see the package installed ahead of time.

Hope this helps!

I changed up the capabilities and the syntax and everything worked.

require 'rubygems'
require 'selenium-webdriver'
require 'uri'
require 'appium_lib'
require_relative 'SDK_Navigation'

mySampleApp = SampleApp.new

caps = Selenium::WebDriver::Remote::Capabilities.android
caps['deviceName'] = 'fegero'
caps['platformName'] = 'Android'
caps['app'] = 'c:\users\myfolder\documents\SampleApp_1046.apk'
driver = Selenium::WebDriver.for(
:remote,
:url => "http://127.0.0.1:4723/wd/hub",
:desired_capabilities => caps)

sleep(20)
mySampleApp.PickImagebtn(driver)