Sunday, October 22, 2017

Installing Appium + Node - Mac


Following steps worked for me[On Mac OS]. 

Mac OS : 10.11.6 OS X EI Capitan
Xcode : 8.1
Appium : 1.6.0
Appium GUI : 1.2.3 dmg
npm : 5.4.2(after upgrade)
node: 6.3.0

Prior to this you need to have XCode[for iOS] and Android Studio[for Android] installed in your machine.

For Appium we need to install Node JS and also carthage.



1)  Install Node and set proxy for node.

Download and install this node pkg. It will install npm too.


If your machine is behind a proxy then Set Proxy using below commands

npm set proxy http://<proxy url>:<port>
npm set https.proxy https://<proxy url>:<port>


Set No proxy variable.
export no_proxy=localhost,127.0.0.1
export http_proxy=http://<proxy url>:<port>


2)  Install carthage


3) we need to upgrade the node version and the install appium.

Upgrading npm
sudo npm install npm@latest -g

Set All Proxy and then install appium because it downloads chromedriver.zip using curl
export ALL_PROXY=<proxy url without http>:<port>
export no_proxy=localhost,127.0.0.1
export http_proxy=http://<proxy url>:<port>

npm set proxy http://<proxy url>:<port>
npm set https.proxy https://<proxy url>:<port>

Run 
npm install appium@1.6.0


It will take some 10 min time for installing.

Once the installation is successful. verify appium directory inside node.

cd~ 
/Users/sriramkukkadapu/node_modules/appium

4)
Install appium-doctor
npm install appium-doctor

npm install appium-doctor –g


after it is done type this command. it will show us if anything is wrong.
appium-doctor


If it shows JAVA_HOME bin is not set properly then run this commands or set JAVA bin path.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin


5) To authorize npm for iOS

npm install -g authorize-ios appium-doctor appium-gulp-plugins authorize-ios



6)  Install appium 1.2.4 dmg file. This is for appium GUI
https://github.com/appium/appium-desktop/releases/

Before starting Appium server make sure Xcode is pointed to right path.
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

If Xcode is not set properly errors might come.

In the appium you need to specify the capabilities for appium server to start. I am listing the capabilities which i have used, for iOS and Android apps. modify them accordingly and point appium to your mobile app with "app" : <path> parameter

Once the capabilities are defined(for any deivce ex: iOS or Android)

Open appium(GUI). Click on Start Inspector Session.
Select the configuration(any of the capabilities below) and
Click on Start Session.

Capabilities are below for iOS

{
  "platformName": "iOS",
  "deviceName": "iPhone 7",
  "app": "/Users/sriramkukkadapu/TestApp.app",
  "automationName": “XCUITest”
}


Capabilities for Android

{
  "platformName": "Android",
  "deviceName": "Android Emulator",
  "app": "/Users/sriramkukkadapu/TestAPP.apk",
  "automationName": "Appium",
  "platformVersion": "7.1.1",
  "appPackage": "<app package>",
  "appActivity": “<app activity>”
 "avd": "Nexus_5X_API_25_1"
}

If we dont specify avd prameter
For Android devices(if it says cannot recognize any devices)
then open android studio start any device
and run this command to check the device status. Android_HOME/platform-tools has this command

adb devices

once device is listed and active it will be recognized by appium.


7) To see the list of Android virtual devices.
emulator -list-avds

my mac has below devices

Nexus_5X_API_25_1
Nexus_5X_API_26_-_Android_8.0


use the same name in capabilities as avd name


Note: 

For Android we all know that .apk is the setup file(which will be used to run the application)
For iOS .ipa is the file which user will be able to install the application but to generate a .ipa file apple license is required so there is a separate .app file which XCode tool generates for us to install it on the virtual device and run the application.

So to run the .apk file we need android studio [Emulator]
to run the .app file we need xcode [Simulator]


Tuesday, October 10, 2017

Setting up Android studio and running a apk file in Emulator in Mac

These steps are for Mac machine.

Installing Android Studio

Setting JAVA_HOME
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/
export PATH=$PATH:$JAVA_HOME/bin/
Verify like this : $JAVA_HOME/bin/java -version

Setting GRADLE_USER_HOME
export GRADLE_USER_HOME=/scratch/skukkada/OMC_Softwares/gradle-2.14.1/
export PATH=$PATH:/scratch/skukkada/OMC_Softwares/gradle-2.14.1/bin

For Mac, download android-studio(which is a dmg file supported for mac)
open the dmg file and drag dmg into applications. it will show Android-Studio in “Finder” or "Launchpad"
open android studio, click next, select default sdk path click on next..
it would ask for proxy give the proxy details(if you are behind a proxy)

Proxy:
http, host='<proxy url>' port=<port> --proxy=http "platforms;android-25”
enable https also

Click next.. Downloading of the components will start.
It will take lot of time even after connecting to lan.

once the android studio opens, go to SDK manager and in Platform, select version from 7,6,5(all) and update. in SDK tools we need emulator. download these packages.


(Not Required) Setting path for Android home
   export ANDROID_HOME=/Applications/ADT/sdk
   export PATH=$PATH:$ANDROID_HOME/bin

For Mac
Android studio automatically sets Android_Home to : /Users/sriramkukkadapu/Library/Android/sdk

if it is not set you can run: export ANDROID_HOME=$HOME/Library/Android/sdk

Installation is done. Now we need to create a AVD(Android Virtual Device or Emulator)

AVD Manager (Or) Emulator

First set these env variables. In Terminal

export ANDROID_TOOLS=$ANDROID_HOME/tools
export ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS

Go to Android Studio-> AVD Manager -> create virtual device.
Click Next(device selection)
In the System image. install all the android version images(click download link in each of them and download the packages)
Install 8,7 versions

Once the device is ready, 
Open Emulator


we need to install the apk file of the application which you want to run in Emulator
In the mac terminal go to the path where .apk file is present and run this command.

adb install <testapp.apk>

This command will install the application in the emulator(which is currently running).



Sunday, October 8, 2017

Windows - Schedule Testng.xml to run automatically without Jenkins

1st create a batch file to run Testng.xml automatically.
For Maven project the batch file looks similar to below. If your project is not a maven project(you need to specify the path of the libs explicitly)

set projectLocation=<C:\SVN-IndirectWorkspace\...>
cd %projectLocation%
mvn clean test -DsuiteXmlFile=<Path of testng.xml>
pause

Ex(Maven Project):

set projectLocation=C:\SVN-IndirectWorkspace\TestProj\
cd %projectLocation%
mvn clean test -DsuiteXmlFile=testng.xml
pause

Ex(Normal Project):

set projectLocation=C:\GitRapo\MyProject
cd C:\GitRapo\MyProject
set classpath=C:\GitRapo\MyProject\bin;C:\GitRapo\MyProject\lib\*
java org.testng.TestNG C:\GitRapo\MyProject\testng.xml

Test the bat file once by executing it.

Now we can create a Windows Task to run this batch file on the desired time(Daily/weekly etc).

Follow the steps in this blog post:

http://sriramkukkadapu.blogspot.in/2017/08/how-to-schedule-batch-file-to-run.html




How to avoid our mails going to spam - FIx the issue in 3 simple steps

If you see our emails from (info@jobcurator.in) are going to spam, fix it using below steps. Note: Try this in desktop/laptop 1) Go to any...