APPIUM:在android 4.4.2上测试Salesforce1 android应用程序时,切换到webview时APPIUM出现问题

APPIUM:在android 4.4.2上测试Salesforce1 android应用程序时,切换到webview时APPIUM出现问题,android,selenium-webdriver,automated-tests,appium,Android,Selenium Webdriver,Automated Tests,Appium,当我尝试在我的android版本4.4.2上自动运行Salesforce1应用程序时,该应用程序会被安装,单击接受用户协议(我同意),然后单击登录按钮。然后,上下文切换到webview,这就是问题所在 这是我的密码: import io.appium.java_client.TouchAction; import io.appium.java_client.android.AndroidDriver; import java.io.File; import java.net.Malformed

当我尝试在我的android版本4.4.2上自动运行Salesforce1应用程序时,该应用程序会被安装,单击接受用户协议(我同意),然后单击登录按钮。然后,上下文切换到webview,这就是问题所在

这是我的密码:

import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
// import org.testng.annotations.Test;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Demo1 {

@Test
public void demoTest() throws MalformedURLException, InterruptedException{

// AndroidDriver driver;

File classpathRoot = new File(System.getProperty("user.dir")); // path to Eclipse project
File appDir = new File(classpathRoot, "/apk"); // path to <project folder>/Contact Manager
File app = new File(appDir, "com.salesforce.chatter.apk");// path to <project folder>/Contact Manager/ContactManager.apk

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME,""); 
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("takesScreenshot","true"); 
capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
capabilities.setCapability("deviceName", "3204481ceddaa1d7");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.salesforce.chatter");
capabilities.setCapability("appActivity", "com.salesforce.chatter.Chatter");
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

new WebDriverWait(driver,10).until(ExpectedConditions.visibilityOfElementLocated(By.id("com.salesforce.chatter:id/mi_accept")));

WebElement addContactButton = driver.findElement(By.id("com.salesforce.chatter:id/mi_accept"));
addContactButton.click();

WebElement loginButton = driver.findElement(By.id("com.salesforce.chatter:id/log_in"));
loginButton.click();

Thread.sleep(9000);

 TouchAction touch = new TouchAction(driver);
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
    System.out.println(contextName);
  if (contextName.contains("WEBVIEW")){
       driver.context(contextName);

    } 
 } 

WebElement username = driver.findElement(By.id("username"));
username.click();
username.sendKeys("************");


WebElement password = driver.findElement(By.id("password"));
password.click();
password.sendKeys("***********");

WebElement loginButton1 = driver.findElement(By.id("Login"));
loginButton1.click();

}
}
import io.appium.java\u client.TouchAction;
导入io.appium.java_client.android.AndroidDriver;
导入java.io.File;
导入java.net.MalformedURLException;
导入java.net.URL;
导入java.util.Set;
导入org.junit.Test;
导入org.openqa.selenium.By;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.remote.CapabilityType;
导入org.openqa.selenium.remote.DesiredCapabilities;
导入org.openqa.selenium.support.ui.ExpectedConditions;
//导入org.testng.annotations.Test;
导入org.openqa.selenium.support.ui.WebDriverWait;
公开课演示1{
@试验
public void demoest()引发错误的DurException、InterruptedException{
//机器人驱动;
File classpathRoot=新文件(System.getProperty(“user.dir”);//Eclipse项目的路径
File appDir=new File(classpathRoot,“/apk”);//指向/Contact-Manager的路径
File app=new File(appDir,“com.salesforce.chatter.apk”);//指向/Contact-Manager/ContactManager.apk的路径
DesiredCapabilities=新的DesiredCapabilities();
setCapability(CapabilityType.BROWSER_NAME,“”);
能力。设置能力(“平台名”、“安卓”);
能力。设置能力(“takesScreenshot”、“true”);
CapabilityType.VERSION,“4.4.2”);
能力。设置能力(“deviceName”、“3204481ceddaa1d7”);
setCapability(“app”,app.getAbsolutePath());
setCapability(“appPackage”、“com.salesforce.chatter”);
capabilities.setCapability(“appActivity”、“com.salesforce.chatter.chatter”);
AndroidDriver=新的AndroidDriver(新URL(“http://127.0.0.1:4723/wd/hub(能力),;
新的WebDriverWait(驱动程序,10)。直到(预期条件。元素的可视性定位(By.id(“com.salesforce.chatter:id/mi_accept”));
WebElement addContactButton=driver.findElement(By.id(“com.salesforce.chatter:id/mi_accept”);
addContactButton.click();
WebElement loginButton=driver.findElement(By.id(“com.salesforce.chatter:id/log_in”);
loginButton.click();
睡眠(9000);
TouchAction touch=新的TouchAction(驾驶员);
设置contextNames=driver.getContextHandles();
for(字符串contextName:contextName){
System.out.println(contextName);
if(contextName.contains(“WEBVIEW”)){
驱动程序上下文(contextName);
} 
} 
WebElement用户名=driver.findElement(By.id(“用户名”);
username.click();
username.sendKeys(“*************”);
WebElement password=driver.findElement(By.id(“密码”);
密码。单击();
密码。发送密钥(“**********”);
WebElement loginButton1=driver.findElement(By.id(“Login”));
loginButton1.单击();
}
}
日志:

info:-->POST/wd/hub/session{“desiredCapabilities”:{“app”:“C:\Appium\u Test\apk\com.salesforce.chatter.apk”、“appPackage”:“com.salesforce.chatter”、“appActivity”:“com.salesforce.chatter.chatter”、“browserName”:“takesscreensshot”:“true”、“platformName”:“Android”、“version”:“4.4.4.2”、“deviceName”:“3204481ceddaa1d7”}
信息:客户端用户代理字符串:Apache HttpClient/4.3.6(java 1.5)
警告:将cap takesScreenshot从字符串转换为布尔值。这可能会导致意外行为。
信息:[调试]提供了以下所需功能,但appium无法识别。它们将被传递到此服务器上运行的任何其他服务:takesScreenshot,版本
信息:[调试]使用来自所需caps的本地应用程序:C:\Appium\u Test\apk\com.salesforce.chatter.apk
信息:[调试]创建新的应用程序会话151a20b1-698d-497f-baf1-190e64e838c1
信息:启动android appium
信息:[调试]正在获取Java版本
信息:Java版本为:1.8.0_45
信息:[调试]检查adb是否存在
信息:[调试]从C:\Users\USER\AppData\Local\Android\sdk\platform tools\adb.exe使用adb
信息:[调试]将chromedriver二进制文件设置为:C:\Program Files(x86)\Appium\node\U modules\Appium\build\chromedriver\windows\chromedriver.exe
信息:[调试]是否使用快速重置?真的
信息:[调试]正在为会话准备设备
信息:[调试]检查应用程序是否实际存在
信息:检索设备
信息:[调试]正在尝试查找已连接的android设备
信息:[调试]正在获取连接的设备。。。
信息:[调试]正在执行cmd:C:\Users\USER\AppData\Local\Android\sdk\platform tools\adb.exe devices
信息:[调试]已连接1个设备
信息:找到设备3204481ceddaa1d7
信息:[调试]将设备id设置为3204481ceddaa1d7
信息:[调试]等待设备准备就绪并响应shell命令(超时=5)
信息:[调试]正在执行cmd:C:\Users\USER\AppData\Local\Android\sdk\platform tools\adb.exe-s 3204481ceddaa1d7等待设备
信息:[调试]正在执行cmd:C:\Users\USER\AppData\Local\Android\sdk\platform tools\adb.exe-s 3204481ceddaa1d7 shell“echo'ready'”
信息:[调试]正在启动logcat捕获
信息:[调试]正在获取设备API级别
信息:[调试]正在执行cmd:C:\Users\USER\AppData\Local\Android\sdk\platform tools\adb.exe-s 3204481ceddaa1d7 shell“getprop ro.build.version.sdk”
信息:[调试]设备处于API级别19
信息:设备API级别为:19
信息:[调试]正在提取语言的字符串:默认值
信息:[调试]正在执行cmd:C:\Users\USER\AppData\Local\Android\sdk\platform tools\adb.exe-s 3204481ceddaa1d7 shell“getprop persist.sys.language”
信息:[调试]当前设备persist.sys.language:en
信息:[调试]java-jar“C:\ProgramFiles(x86)\Appium\node\u modules\Appium\node\u modules\Appium adb\jars\Appium\u apk\u tools.jar”“stringsFromApk”“C:\Appium\u Test\apk\com.salesforce.chatter.apk”“C:\Users\USER\USER\AppData\Local\Temp\com.salesforce.chatter”en
信息:[调试]语言“en”没有strings.xml,正在获取默认strings.xml
信息:[调试]java-jar“C:\ProgramFiles(x86)\Appium\node\u modules\Appium\node\u modules\app
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\Appium_Test\apk\com.salesforce.chatter.apk","appPackage":"com.salesforce.chatter","appActivity":"com.salesforce.chatter.Chatter","browserName":"","takesScreenshot":"true","platformName":"Android","version":"4.4.2","deviceName":"3204481ceddaa1d7"}}

info: Client User-Agent string: Apache-HttpClient/4.3.6 (java 1.5)
warn: Converting cap takesScreenshot from string to boolean. This might cause unexpected behavior.
info: [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. : takesScreenshot, version
info: [debug] Using local app from desired caps: C:\Appium_Test\apk\com.salesforce.chatter.apk
info: [debug] Creating new appium session 151a20b1-698d-497f-baf1-190e64e838c1
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_45
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe
info: [debug] Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 3204481ceddaa1d7
info: [debug] Setting device id to 3204481ceddaa1d7
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 wait-for-device
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: en
info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\Appium_Test\apk\com.salesforce.chatter.apk" "C:\Users\USER\AppData\Local\Temp\com.salesforce.chatter" en
info: [debug] No strings.xml for language 'en', getting default strings.xml
info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\Appium_Test\apk\com.salesforce.chatter.apk" "C:\Users\USER\AppData\Local\Temp\com.salesforce.chatter"
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 push "C:\Users\USER\AppData\Local\Temp\com.salesforce.chatter\strings.json" /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\USER\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe dump xmltree C:\Appium_Test\apk\com.salesforce.chatter.apk AndroidManifest.xml
info: [debug] Set app process to: com.salesforce.chatter
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for C:\Appium_Test\apk\com.salesforce.chatter.apk.
info: [debug] executing cmd: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" C:\Appium_Test\apk\com.salesforce.chatter.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Appium_Test\apk\com.salesforce.chatter.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\Users\USER\AppData\Local\Android\sdk\build-tools\22.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\build-tools\22.0.1\zipalign.exe -f 4 C:\Appium_Test\apk\com.salesforce.chatter.apk C:\Users\USER\AppData\Local\Temp\115530-16608-1ipilb4\appium.tmp
info: [debug] MD5 for app is c68403dd22fea8f87f4b2785ae30234a
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "ls /data/local/tmp/c68403dd22fea8f87f4b2785ae30234a.apk"
info: [debug] Getting install status for com.salesforce.chatter
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "pm list packages -3 com.salesforce.chatter"
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "am force-stop com.salesforce.chatter"
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "pm clear com.salesforce.chatter"
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 push "C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.salesforce.chatter -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "dumpsys window"
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data\/local\/tmp","status":0}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.salesforce.chatter/com.salesforce.chatter.Chatter"
info: [debug] Waiting for pkg "com.salesforce.chatter" and activity "com.salesforce.chatter.Chatter" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "dumpsys window windows"
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "getprop ro.build.version.release"
info: [debug] Device is at release version 4.4.2
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 151a20b1-698d-497f-baf1-190e64e838c1
info: <-- POST /wd/hub/session 303 19573.660 ms - 74 
info: --> GET /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1 {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Appium_Test\apk\com.salesforce.chatter.apk","appPackage":"com.salesforce.chatter","appActivity":"com.salesforce.chatter.Chatter","browserName":"","takesScreenshot":true,"platformName":"Android","version":"4.4.2","deviceName":"3204481ceddaa1d7"},"app":"C:\Appium_Test\apk\com.salesforce.chatter.apk","appPackage":"com.salesforce.chatter","appActivity":"com.salesforce.chatter.Chatter","platformName":"Android","version":"4.4.2","deviceName":"3204481ceddaa1d7"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- GET /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1 200 8.267 ms - 796 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Appium_Test\apk\com.salesforce.chatter.apk","appPackage":"com.salesforce.chatter","appActivity":"com.salesforce.chatter.Chatter","browserName":"","takesScreenshot":true,"platformName":"Android","version":"4.4.2","deviceName":"3204481ceddaa1d7"},"app":"C:\Appium_Test\apk\com.salesforce.chatter.apk","appPackage":"com.salesforce.chatter","appActivity":"com.salesforce.chatter.Chatter","platformName":"Android","version":"4.4.2","deviceName":"3204481ceddaa1d7"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element {"using":"id","value":"com.salesforce.chatter:id/mi_accept"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.salesforce.chatter:id/mi_accept","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.salesforce.chatter:id/mi_accept","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.salesforce.chatter:id/mi_accept using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.salesforce.chatter:id/mi_accept]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"1"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element 200 1050.164 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> GET /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element/1/displayed {}
info: [debug] Pushing command to appium work queue: ["element:getAttribute",{"elementId":"1","attribute":"displayed"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getAttribute","params":{"elementId":"1","attribute":"displayed"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getAttribute
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"true","status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- GET /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element/1/displayed 200 418.928 ms - 76 {"status":0,"value":true,"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element {"using":"id","value":"com.salesforce.chatter:id/mi_accept"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.salesforce.chatter:id/mi_accept","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.salesforce.chatter:id/mi_accept","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.salesforce.chatter:id/mi_accept using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.salesforce.chatter:id/mi_accept]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"2"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"2"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element 200 90.549 ms - 87 {"status":0,"value":{"ELEMENT":"2"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element/2/click {"id":"2"}
info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"2"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element/2/click 200 672.368 ms - 76 {"status":0,"value":true,"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element {"using":"id","value":"com.salesforce.chatter:id/log_in"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.salesforce.chatter:id/log_in","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.salesforce.chatter:id/log_in","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.salesforce.chatter:id/log_in using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.salesforce.chatter:id/log_in]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"3"},"status":0}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"3"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element 200 559.730 ms - 87 {"status":0,"value":{"ELEMENT":"3"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element/3/click {"id":"3"}
info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"3"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"3"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element/3/click 200 3647.621 ms - 76 {"status":0,"value":true,"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> GET /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s 3204481ceddaa1d7 shell "cat /proc/net/unix"
info: [debug] Available contexts: 
info: [debug] []
info: [debug] Available contexts: NATIVE_APP
info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP"],"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- GET /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/contexts 200 395.859 ms - 86 {"status":0,"value":["NATIVE_APP"],"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: --> POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element {"using":"id","value":"username"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"username","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"username","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding username using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.salesforce.chatter:id/username]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=android:id/username]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=username, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding username using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.salesforce.chatter:id/username]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=android:id/username]
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[DESCRIPTION=username, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 1062ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"151a20b1-698d-497f-baf1-190e64e838c1"}
info: <-- POST /wd/hub/session/151a20b1-698d-497f-baf1-190e64e838c1/element 500 1064.592 ms - 195
Set<String> contextHandles = driver.getContextHandles();
for (String s : contextHandles) {
    System.out.println("Context : " + s);
//if context contains webview then set the webview context
    if (s.contains("WEBVIEW")) {

        //System.out.println("Set the Context NATIVE to WEBVIEW");
        driver.context(s);
    }
}

driver.findElement(By.xpath("//android.widget.EditText[@index='0']")).sendKeys(EMAIL);
//System.out.println("UserName Entered");
//sleep(3000);

driver.findElement(By.xpath("//android.widget.EditText[@index='1']")).sendKeys(PASSWORD);
//System.out.println("Password Entered");