@afwang Thanks for the reply
@pr4bh4sh
I haven’t tried running two instances. I have running one appium instances and trying to access driver value in two separate classes (TestLogin and TestLogout) as mentioned above. First class getting the driver but when test case execution completed in First class, the second class didn’t get the driver value (it getting as ‘null’). As I mentioned above, I am not declared the driver as static in base class because I need to run the scripts in parallel using two devices. If I declare the driver as static the execution get failed all the time (partially execute in device one and execution will stop when second device start execution). So I removed the static concept. In case of non-static declaration if I written all the test cases in First class (TestLogin) it will working parallel in two devices without any issues.
Could you please suggest anyway to get the driver value in second and consecutive classes if I declare the driver as non-static variable?
Here is the testng.xml details:

Appium Logs:
[TestNG] Running:
E:\Panippura\Automation\RVSAutomationTestScripts\testng.xml
Starting Appium Server…
e[36minfoe[39m: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
e[36minfoe[39m: Appium REST http interface listener started on 127.0.0.1:50672
e[36minfoe[39m: [debug] Non-default server args: {“udid”:“4d003e9be03d91df”,“address”:“127.0.0.1”,“port”:50672,“bootstrapPort”:50673,“noReset”:true,“chromeDriverPort”:50674}
e[36minfoe[39m: Console LogLevel: debug
Appium Successfuly Started…
Loading Driver…
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/sessione[39m e[90m{“desiredCapabilities”:{“appPackage”:“com.zervant.android.views”,“appActivity”:“com.zervant.android.views.ZLandingPageActivity”,“udid”:“4d003e9be03d91df”,“platformName”:“Android”,“deviceName”:“Samsung Galaxy S4”,“version”:“5.1”}}e[39m
e[36minfoe[39m: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_11)
e[36minfoe[39m: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version
e[36minfoe[39m: [debug] Didn’t get app but did get Android package, will attempt to launch it on the device
e[36minfoe[39m: [debug] Creating new appium session 0c25632a-f9f3-41d7-b856-c77e9a0063a3
e[36minfoe[39m: Starting android appium
e[36minfoe[39m: [debug] Getting Java version
e[36minfoe[39m: Java version is: 1.8.0_11
e[36minfoe[39m: [debug] Checking whether adb is present
e[36minfoe[39m: [debug] Using adb from E:\AndroidDev\android-sdk\platform-tools\adb.exe
e[33mwarne[39m: No app capability, can’t parse package/activity
e[36minfoe[39m: [debug] Using fast reset? false
e[36minfoe[39m: [debug] Preparing device for session
e[36minfoe[39m: [debug] Not checking whether app is present since we are assuming it’s already on the device
e[36minfoe[39m: Retrieving device
e[36minfoe[39m: [debug] Trying to find a connected android device
e[36minfoe[39m: [debug] Getting connected devices…
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe devices
e[36minfoe[39m: [debug] 1 device(s) connected
e[36minfoe[39m: Found device 4d003e9be03d91df
e[36minfoe[39m: [debug] Setting device id to 4d003e9be03d91df
e[36minfoe[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df wait-for-device
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “echo ‘ready’”
e[36minfoe[39m: [debug] Starting logcat capture
e[36minfoe[39m: [debug] Getting device API level
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “getprop ro.build.version.sdk”
e[36minfoe[39m: [debug] Device is at API Level 21
e[36minfoe[39m: Device API level is: 21
e[36minfoe[39m: [debug] Extracting strings for language: default
e[36minfoe[39m: [debug] Apk doesn’t exist locally
e[36minfoe[39m: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “rm -rf /data/local/tmp/strings.json”
e[36minfoe[39m: [debug] Not uninstalling app since server not started with --full-reset
e[36minfoe[39m: [debug] Skipping install since we launched with a package instead of an app path
e[36minfoe[39m: [debug] Forwarding system:50673 to device:4724
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df forward tcp:50673 tcp:4724
e[36minfoe[39m: [debug] Pushing appium bootstrap to device…
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df push “C:\Program Files\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
e[36minfoe[39m: [debug] Pushing settings apk to device…
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df install “C:\Program Files\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
e[36minfoe[39m: [debug] Pushing unlock helper app to device…
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df install “C:\Program Files\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
e[36minfoe[39m: Starting App
e[36minfoe[39m: [debug] Attempting to kill all ‘uiautomator’ processes
e[36minfoe[39m: [debug] Getting all processes with ‘uiautomator’
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “ps ‘uiautomator’”
e[36minfoe[39m: [debug] No matching processes found
e[36minfoe[39m: [debug] Running bootstrap
e[36minfoe[39m: [debug] spawning: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.zervant.android.views -e disableAndroidWatchers false
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunnere[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServere[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrape[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1e[39m
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Loading json…
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
e[36minfoe[39m: [debug] Waking up device if it’s not alive
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“wake”,{}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Client connected
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“wake”,“params”:{}}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: wake
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “dumpsys window”
e[36minfoe[39m: [debug] Screen already unlocked, continuing.
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:"/data/local/tmp"}
e[36minfoe[39m: [debug] dataDir set to: /data/local/tmp
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“compressedLayoutHierarchy”,{“compressLayout”:false}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“compressedLayoutHierarchy”,“params”:{“compressLayout”:false}}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:false}
e[36minfoe[39m: [debug] Getting device API level
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “getprop ro.build.version.sdk”
e[36minfoe[39m: [debug] Device is at API Level 21
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.zervant.android.views/com.zervant.android.views.ZLandingPageActivity”
e[36minfoe[39m: [debug] Waiting for pkg “com.zervant.android.views” and activity “com.zervant.android.views.ZLandingPageActivity” to be focused
e[36minfoe[39m: [debug] Getting focused package and activity
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “dumpsys window windows”
e[36minfoe[39m: [debug] executing cmd: E:\AndroidDev\android-sdk\platform-tools\adb.exe -s 4d003e9be03d91df shell “getprop ro.build.version.release”
e[36minfoe[39m: [debug] Device is at release version 5.0.1
e[36minfoe[39m: [debug] Device launched! Ready for commands
e[36minfoe[39m: [debug] Setting command timeout to the default of 60 secs
e[36minfoe[39m: [debug] Appium session started with sessionId 0c25632a-f9f3-41d7-b856-c77e9a0063a3
e[36minfoe[39m: e[37m<-- POST /wd/hub/session e[39me[36m303e[39me[90m 18896.597 ms - 74e[39m e[90me[39m
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3e[39m e[90m{}e[39m
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“5.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“appPackage”:“com.zervant.android.views”,“appActivity”:“com.zervant.android.views.ZLandingPageActivity”,“udid”:“4d003e9be03d91df”,“platformName”:“Android”,“deviceName”:“Samsung Galaxy S4”,“version”:“5.1”},“appPackage”:“com.zervant.android.views”,“appActivity”:“com.zervant.android.views.ZLandingPageActivity”,“udid”:“4d003e9be03d91df”,“platformName”:“Android”,“deviceName”:“4d003e9be03d91df”,“version”:“5.1”},“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}
e[36minfoe[39m: e[37m<-- GET /wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3 e[39me[32m200e[39me[90m 11.075 ms - 736e[39m e[90m{“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“5.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“appPackage”:“com.zervant.android.views”,“appActivity”:“com.zervant.android.views.ZLandingPageActivity”,“udid”:“4d003e9be03d91df”,“platformName”:“Android”,“deviceName”:“Samsung Galaxy S4”,“version”:“5.1”},“appPackage”:“com.zervant.android.views”,“appActivity”:“com.zervant.android.views.ZLandingPageActivity”,“udid”:“4d003e9be03d91df”,“platformName”:“Android”,“deviceName”:“4d003e9be03d91df”,“version”:“5.1”},“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3/timeoutse[39m e[90m{“type”:“implicit”,“ms”:10000}e[39m
e[36minfoe[39m: [debug] Set Android implicit wait to 10000ms
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}
e[36minfoe[39m: e[37m<-- POST /wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3/timeouts e[39me[32m200e[39me[90m 3.877 ms - 76e[39m e[90m{“status”:0,“value”:null,“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}e[39m
Driver Successfuly Loaded…
In Script first class>>>>>>>>: Android on LINUX (0c25632a-f9f3-41d7-b856-c77e9a0063a3)
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3/elemente[39m e[90m{“using”:“id”,“value”:“com.zervant.android.views:id/landing_loginbtn”}e[39m
e[36minfoe[39m: [debug] Waiting up to 10000ms for condition
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“id”,“selector”:“com.zervant.android.views:id/landing_loginbtn”,“context”:"",“multiple”:false}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.zervant.android.views:id/landing_loginbtn”,“context”:"",“multiple”:false}}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: find
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Finding com.zervant.android.views:id/landing_loginbtn using ID with the contextId: multiple: false
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.zervant.android.views:id/landing_loginbtn]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“1”}}
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}
e[36minfoe[39m: e[37m<-- POST /wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3/element e[39me[32m200e[39me[90m 323.132 ms - 87e[39m e[90m{“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3/element/1/clicke[39m e[90m{“id”:“1”}e[39m
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“element:click”,{“elementId”:“1”}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“1”}}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: click
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}
e[36minfoe[39m: e[37m<-- POST /wd/hub/session/0c25632a-f9f3-41d7-b856-c77e9a0063a3/element/1/click e[39me[32m200e[39me[90m 878.088 ms - 76e[39m e[90m{“status”:0,“value”:true,“sessionId”:“0c25632a-f9f3-41d7-b856-c77e9a0063a3”}e[39m
In Script second class>>>>>>>>null
com.rvsautomation.exception.AutomationException: com.rvsautomation.exception.AutomationException: By.id: com.zervant.android.views:id/usernamenot found
at com.rvsautomation.actions.SendKeyActionHelper.sendKeys(SendKeyActionHelper.java:121)
at com.testscripts.nativeapp.LoginTest.testLogin(LoginTest.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:822)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1130)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:400)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.rvsautomation.exception.AutomationException: By.id: com.zervant.android.views:id/usernamenot found
at com.rvsautomation.actions.SendKeyActionHelper.sendKeys(SendKeyActionHelper.java:116)
… 21 more
===============================================
Suite
Total tests run: 2, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
Thanks,
Sanoj