Unable to locate "LOG IN" button of facebook android app using appium!

hello,

I have created this script to automate login in to facebook using appium but appium is able to locate the user id and password fields but is not able to locate the log in button of facebook,please tell me where i am getting wrong or what additonal command i have to write.
Here is my script

package com.appium.facebook.androiduiselector;

import io.appium.java_client.android.AndroidDriver;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

public class FacebookLoginTest {

@Test

public void testLoginFB() throws MalformedURLException, InterruptedException
{
DesiredCapabilities capabilities = new DesiredCapabilities() ;
capabilities.setCapability(“automationName”,“Appium”);
capabilities.setCapability(“platformnName”,“Android”);
capabilities.setCapability(“platformVersion”,“5.1.1”);
capabilities.setCapability(“deviceName”,“Nexus 6” );
capabilities.setCapability(“app”,“C:\Users\Jenny\Downloads\facebook.apk”);
capabilities.setCapability(“appPackage”,“com.facebook.katana”);
capabilities.setCapability(“appActivity”, “com.facebook.katana.LoginActivity”);
AndroidDriver driver = new AndroidDriver (new URL (“http://127.0.0.1:4723/wd/hub”), capabilities) ;
driver.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS);

driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_username\")").sendKeys("[email protected]");
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_password\")").sendKeys("xxxxxx");
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_login\").text(\"LOG IN \")").click();
Thread.sleep(8000);

}

}

Please see the error that is displaying

on the node,js and eclipse console in the screenshot attached

We cant’t see anything from your screenshot (logs and errors are truncated). Please paste Appium log and Eclipse console directly. Also paste UI Automator viewer screenshor with the login element selected.

Is is native android context or web context. I presume it would be web context so UIAutomator won;t be able to locate it if it is in web view.

Get the contexts and switch to web view and then try.

Hello Alexis ,

This is my log for appium :

info: → POST /wd/hub/session {“desiredCapabilities”:{“app”:“C:\Users\Jenny\Downloads\facebook.apk”,“appPackage”:“com.facebook.katana”,“appActivity”:“com.facebook.katana.LoginActivity”,“platformnName”:“Android”,“platformVersion”:“5.1.1”,“automationName”:“Appium”,“platformName”:“Android”,“deviceName”:“Nexus 6”}}
info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
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. : platformnName
info: [debug] Using local app from desired caps: C:\Users\Jenny\Downloads\facebook.apk
info: [debug] Creating new appium session f46c7835-31f0-41f7-8f3e-621b5c825c17
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_51
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\adt-bundle-windows\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: D:\adt-bundle-windows\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device ZX1G4292PS
info: [debug] Setting device id to ZX1G4292PS
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS wait-for-device
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: Device API level is: 22
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS 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:\Users\Jenny\Downloads\facebook.apk” “C:\Users\Jenny\AppData\Local\Temp\com.facebook.katana” 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:\Users\Jenny\Downloads\facebook.apk” “C:\Users\Jenny\AppData\Local\Temp\com.facebook.katana”
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS push “C:\Users\Jenny\AppData\Local\Temp\com.facebook.katana\strings.json” /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\adt-bundle-windows\sdk\build-tools\23.0.0\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\build-tools\23.0.0\aapt.exe dump xmltree C:\Users\Jenny\Downloads\facebook.apk AndroidManifest.xml
info: [debug] Set app process to: com.facebook.katana
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for C:\Users\Jenny\Downloads\facebook.apk.
info: [debug] executing cmd: java -jar “C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar” C:\Users\Jenny\Downloads\facebook.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\Jenny\Downloads\facebook.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\adt-bundle-windows\sdk\build-tools\23.0.0\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\build-tools\23.0.0\zipalign.exe -f 4 C:\Users\Jenny\Downloads\facebook.apk C:\Users\Jenny\AppData\Local\Temp\115727-10892-13qggii\appium.tmp
info: [debug] MD5 for app is b47de74c97570143ebd9d3d46682ee2d
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “ls /data/local/tmp/b47de74c97570143ebd9d3d46682ee2d.apk”
info: [debug] Getting install status for com.facebook.katana
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “pm list packages -3 com.facebook.katana”
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “am force-stop com.facebook.katana”
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “pm clear com.facebook.katana”
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS 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: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS 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: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS 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: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.facebook.katana -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] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
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] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “dumpsys window”
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
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] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: [“compressedLayoutHierarchy”,{“compressLayout”:false}]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“/data/local/tmp”}
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: {“status”:0,“value”:false}
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.facebook.katana/com.facebook.katana.LoginActivity”
info: [debug] Waiting for pkg “com.facebook.katana” and activity “com.facebook.katana.LoginActivity” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “dumpsys window windows”
info: [debug] executing cmd: D:\adt-bundle-windows\sdk\platform-tools\adb.exe -s ZX1G4292PS shell “getprop ro.build.version.release”
info: [debug] Device is at release version 5.1.1
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 f46c7835-31f0-41f7-8f3e-621b5c825c17
info: ← POST /wd/hub/session 303 27638.199 ms - 74
info: → GET /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“5.1.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Jenny\Downloads\facebook.apk”,“appPackage”:“com.facebook.katana”,“appActivity”:“com.facebook.katana.LoginActivity”,“platformnName”:“Android”,“platformVersion”:“5.1.1”,“automationName”:“Appium”,“platformName”:“Android”,“deviceName”:“Nexus 6”},“app”:“C:\Users\Jenny\Downloads\facebook.apk”,“appPackage”:“com.facebook.katana”,“appActivity”:“com.facebook.katana.LoginActivity”,“platformnName”:“Android”,“automationName”:“Appium”,“platformName”:“Android”,“deviceName”:“ZX1G4292PS”},“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: ← GET /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17 200 8.633 ms - 828 {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“5.1.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Jenny\Downloads\facebook.apk”,“appPackage”:“com.facebook.katana”,“appActivity”:“com.facebook.katana.LoginActivity”,“platformnName”:“Android”,“platformVersion”:“5.1.1”,“automationName”:“Appium”,“platformName”:“Android”,“deviceName”:“Nexus 6”},“app”:“C:\Users\Jenny\Downloads\facebook.apk”,“appPackage”:“com.facebook.katana”,“appActivity”:“com.facebook.katana.LoginActivity”,“platformnName”:“Android”,“automationName”:“Appium”,“platformName”:“Android”,“deviceName”:“ZX1G4292PS”},“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: → POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/timeouts/implicit_wait {“ms”:100000}
info: [debug] Set Android implicit wait to 100000ms
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: ← POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/timeouts/implicit_wait 200 5.114 ms - 76 {“status”:0,“value”:null,“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: → POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element {“using”:“-android uiautomator”,“value”:“new UiSelector().resourceId("com.facebook.katana:id/login_username")”}
info: [debug] Waiting up to 100000ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_username")”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_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 new UiSelector().resourceId(“com.facebook.katana:id/login_username”) using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_username”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_username”
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[RESOURCE_ID=com.facebook.katana:id/login_username]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding new UiSelector().resourceId(“com.facebook.katana:id/login_username”) using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_username”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_username”
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[RESOURCE_ID=com.facebook.katana:id/login_username]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:7,“value”:“No element found”}
info: [debug] Waited for 237ms so far

info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_username")”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_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 new UiSelector().resourceId(“com.facebook.katana:id/login_username”) using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_username”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_username”
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[RESOURCE_ID=com.facebook.katana:id/login_username]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“1”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: ← POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element 200 77270.269 ms - 87 {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: → POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element/1/value {“id”:“1”,“value”:[“[email protected]”]}
info: [debug] Pushing command to appium work queue: [“element:setText”,{“elementId":“1”,“text”:"[email protected]”,“replace”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:setText”,“params”:{“elementId":“1”,“text”:"[email protected]”,“replace”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Clearing text not successful. Attempting to clear by selecting all and deleting.
info: [debug] [BOOTSTRAP] [debug] Text remains after clearing, but it appears to be hint text.
info: [debug] [BOOTSTRAP] [debug] Text not cleared. Assuming remainder is hint text.
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: [email protected]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: ← POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element/1/value 200 13234.222 ms - 76 {“status”:0,“value”:true,“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: → POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element {“using”:“-android uiautomator”,“value”:“new UiSelector().resourceId("com.facebook.katana:id/login_password")”}
info: [debug] Waiting up to 100000ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_password")”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_password")”,“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 new UiSelector().resourceId(“com.facebook.katana:id/login_password”) using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_password”)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_password”
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[RESOURCE_ID=com.facebook.katana:id/login_password]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“2”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“2”},“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: ← POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element 200 939.558 ms - 87 {“status”:0,“value”:{“ELEMENT”:“2”},“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: → POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element/2/value {“id”:“2”,“value”:[“XXXXX”]}
info: [debug] Pushing command to appium work queue: [“element:setText”,{“elementId”:“2”,“text”:“XXXXX”,“replace”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:setText”,“params”:{“elementId”:“2”,“text”:“XXXXX”,“replace”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: xxxxx
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: ← POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element/2/value 200 4892.618 ms - 76 {“status”:0,“value”:true,“sessionId”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: → POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element {“using”:“-android uiautomator”,“value”:“new UiSelector().resourceId("com.facebook.katana:id/login_login").text("LOG IN ")”}
info: [debug] Waiting up to 100000ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_login").text("LOG IN ")”,“context”:“”,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_login").text("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 new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text("LOG IN ") using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text(“LOG IN “)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_login”
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “LOG IN "
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=LOG IN , RESOURCE_ID=com.facebook.katana:id/login_login]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text(“LOG IN “) using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text(“LOG IN “)
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_login”
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “LOG IN "
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=LOG IN , RESOURCE_ID=com.facebook.katana:id/login_login]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:7,“value”:“No element found”}
info: [debug] Waited for 99735ms so far
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:”-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_login").text("LOG IN ")”,“context”:””,“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:”-android uiautomator”,“selector”:“new UiSelector().resourceId("com.facebook.katana:id/login_login").text("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 new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text("LOG IN ") using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text("LOG IN ")
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_login”
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: "LOG IN "
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=LOG IN , RESOURCE_ID=com.facebook.katana:id/login_login]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text("LOG IN ") using ANDROID_UIAUTOMATOR with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Parsing selector: new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text("LOG IN ")
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: “com.facebook.katana:id/login_login”
info: [debug] [BOOTSTRAP] [debug] UiSelector coerce type: class java.lang.String arg: "LOG IN "
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[TEXT=LOG IN , RESOURCE_ID=com.facebook.katana:id/login_login]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:7,“value”:“No element found”}
info: [debug] Condition unmet after 100498ms. 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”:“f46c7835-31f0-41f7-8f3e-621b5c825c17”}
info: ← POST /wd/hub/session/f46c7835-31f0-41f7-8f3e-621b5c825c17/element 500 100500.869 ms - 195

Log in Ecipse Console:-
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 100.35 seconds
For documentation on this error, please visit: Selenium
Build info: version: ‘2.46.0’, revision: ‘61506a4624b13675f24581e453592342b7485d71’, time: ‘2015-06-04 10:22:50’
System info: host: ‘Jenny-PC’, ip: ‘192.168.1.2’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_51’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=C:\Users\Jenny\Downloads\facebook.apk, appPackage=com.facebook.katana, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=ZX1G4292PS, platform=LINUX, appActivity=com.facebook.katana.LoginActivity, desired={app=C:\Users\Jenny\Downloads\facebook.apk, appPackage=com.facebook.katana, appActivity=com.facebook.katana.LoginActivity, platformnName=Android, platformVersion=5.1.1, automationName=Appium, platformName=Android, deviceName=Nexus 6}, platformnName=Android, platformVersion=5.1.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, browserName=Android, takesScreenshot=true, javascriptEnabled=true, platformName=Android}]
Session ID: f0d87833-7443-4f31-a948-864ef32109d8
*** Element info: {Using=-android uiautomator, value=new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text("LOG IN ")}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:27)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:358)
at io.appium.java_client.android.AndroidDriver.findElementByAndroidUIAutomator(AndroidDriver.java:266)
at com.appium.facebook.androiduiselector.FacebookLoginTest.testLoginFB(FacebookLoginTest.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Try to remove the second space in "LOG IN " -> “LOG IN”.
Did it not work with the ID alone ? Like you did with the previus two ?
You can also use other functions, like :

driver.findElementById("com.facebook.katana:id/login_login").click();

Hi Alexis,

Thanks a ton,you helped me,it was 2nd space which was failing the script.
Thanks again,i am new to automation and programming so help like this will be appreciated.

Thanks,

Jenny

Hello,

Script ran sucessfully when i made correction as you mentioned. but a new problem happening now.
Password is getting appended in user id field after the email but eclipse no sign of error.
I am stuck again now.
I tried shutting the eclipse and restarting it but no solution.

Did you just remove the space, or did you change the find methods ? Was the problem already present but unnoticed or did it appear with latest modification ?

It appeared with latest modification after i made correction as per your script which you told me

Could you paste your new code then ?

Hi Alexis,
The new code is same as previous only the space removed after “LOG IN” which you told me previosly,

Here is the code

package com.appium.facebook.androiduiselector;

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

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

public class FacebookLoginTest {

@Test

public void testLoginFB() throws MalformedURLException, InterruptedException
{
DesiredCapabilities capabilities = new DesiredCapabilities() ;
capabilities.setCapability(“automationName”,“Appium”);
capabilities.setCapability(“platformnName”,“Android”);
capabilities.setCapability(“platformVersion”,“5.1.1”);
capabilities.setCapability(“deviceName”,“Nexus 6” );
capabilities.setCapability(“app”,“C:\Users\Jenny\Downloads\facebook.apk”);
capabilities.setCapability(“appPackage”,“com.facebook.katana”);
capabilities.setCapability(“appActivity”, “com.facebook.katana.LoginActivity”);
AndroidDriver driver = new AndroidDriver (new URL (“http://127.0.0.1:4723/wd/hub”), capabilities) ;
driver.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS);

driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_username\")").sendKeys("[email protected]");
driver.sendKeyEvent(AndroidKeyCode.ENTER);
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_password\")").sendKeys("XXXXX");
driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.facebook.katana:id/login_login\").text(\"LOG IN\")").click();
Thread.sleep(8000);

}

}

That line was not there previously, did you try to remove it ?

Hi alexis i added this line so as to force it to go to password field,
but now its working as in entered this line also

driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(“com.facebook.katana:id/login_password”)”).click();

Thanks alexix :smile:

Hi 907howard-

wat we will do after clicking on login button:-
i.e
driver.findElementByAndroidUIAutomator(“new UiSelector().resourceId(“com.facebook.katana:id/login_login”).text(“LOG IN”)”).click();

after executing this line of code, there is another screen which needs affirmation of facebook login for my app.

“Continue as XXXX”

app will receive:

  1. your public profile

  2. Your friend list

  3. email address
    Edit

           OK
    

now how i can check when OK button clicked ?
or what is id of that button ?

Can you help me. please
Thanks

Hi Alexis,

How can I handle on clicking the facebook login button on ios app then redirects to ‘m.facebook.login’ page and then enter login details and back to the app?

And also do you know how to handle inbuilt and featured popups in ios app

Use this code may b its work:
driver.findElement(By.id(“com.android.chrome:id/url_bar”)).sendKeys(“https://www.facebook.com/”);
driver.pressKeyCode(66);
Thread.sleep(5000);
driver.findElement(By.xpath("//[@content-desc=‘Email address or phone number’]")).sendKeys(“sandeep”);
driver.hideKeyboard();
driver.findElement(By.xpath("//
[@class=‘android.widget.EditText’][@NAF=‘true’]")).click();
driver.findElement(By.xpath("//[@class=‘android.widget.EditText’][@NAF=‘true’]")).sendKeys(“314564”);
driver.findElement(By.xpath("//
[@content-desc='Log In ']")).click();
Thread.sleep(5000);