Appium for WebApp Automation in Ruby

1| Download Appium Desktop

https://github.com/appium/appium-desktop/releases

2| Open and click on Start Server

3| Now, download the Appium gem, appium_lib

gem install appium_lib

or, place the library name inside Gemfile and run bundle install

gem 'appium_lib'

4| If you are using cucumber, import the library inside env.rb file

require 'appium_lib'

5| Add capabilities before starting Appium server

caps = {
      caps: {
          platformName: "Android",
          deviceName: "Pixel_2",
          browserName: 'Chrome'
      }
  }
@driver = Appium::Driver.new(caps, true).start_driver

Done!

Advertisements

Setup Android Emulator for Local Env

The core idea of this post is to make sure the local URL being whitelisted in the emulator host file.

1| Navigate to Android sdk tools

/Users/username/Library/Android/sdk/tools

2| Open Android Studio, go to Tools > Android > AVD Manager

3| Get the Android Virtual Device name

4| Now, run the avd in writable mode

./emulator -avd avd_name -writable-system

config partition-size if needed

./emulator -avd avd_name -partition-size 512 -writable-system

5| Now, provide root access to the adb shell to access system files; if not, adb remount doesn’t work.

adb root

6| adb remount changes the system in writable mode

adb remount

7| the text ‘hosts’ can be of any name; pull it and remodify the host file.

adb pull /system/etc/hosts hosts

8| Edit the created hosts file by whitelisting urls for the specific IP

vi hosts

9| Now, push the hosts file with white-listed IPs to emulator env

adb push hosts /system/etc/hosts

Done!