.click() is not working

I’m new to appium, .click () is not working …i have entered text, attributes properly but not working
Here is my code:
public class Base1 extends Test{

public static void main(String[] args) throws MalformedURLException {
	// TODO Auto-generated method stub
	
	AndroidDriver<AndroidElement> driver1=capabilities();
	System.out.println("Test1");
	driver1.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
	//driver1.findElementsByXPath("//*[@content-desc='Animation' and @index='2']");
	
	
	driver1.findElementByXPath("//android.widget.TextView[@content-desc='Preference']").click();
	//driver1.findElement(By.xpath("android.widget.TextView[@text='Preference']")).click();
	//driver1.findElement(By.xpath("android.widget.TextView[@index='9']")).click();
	//driver1.findElement(By.xpath("android.widget.TextView[@content-desc='Content']")).click();
	//driver1.findElement(By.xpath("//*[@content-desc = 'Content']")).click();
//driver1.findElementByXPath("//android.widget.TextView[@text='Preference']");
	/* driver1.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	//to click on specific object/position on a screen
	driver1.findElementByXPath("//android.widget.TextView[text()='Preference']").click();
	driver1.findElementByXPath("//android.widget.TextView[text()='3. Preference dependencies']").click();
	//finding element by ID
	driver1.findElementById("android:id/checkbox").click();
	// 
	driver1.findElementByXPath("//android.widget.RelativeLayout)[2]").click();   
*/
	
	//================ 14/6/19
//	MobileElement pre = (MobileElement)(driver1.findElement(By.name("Preference")));
	//pre.click();

I have entered soo many elements to move by clicking on the api but could not make it. .

driver.findElementByXPath("//android.widget.TextView[@text=‘Preference’]").click();

remove comment from second command line it’s perfect one. first one is improper.

Thank you for your reply @chetan_thummar …I have tried running the code
its not working

where is error log. for better understanding we need log.

This the log :
[Appium] Welcome to Appium v1.12.1

[Appium] Appium REST http interface listener started on 0.0.0.0:4723

[HTTP] --> POST /wd/hub/session

[HTTP] {“desiredCapabilities”:{“appActivity”:".ApiDemos",“appPackage”:“io.appium.android.apis”,“platformVersion”:“8.1.0”,“platformName”:“Android”,“udid”:“5200a8764f5ac445”,“deviceName”:“GAlaxy J7 NXT”},“capabilities”:{“firstMatch”:[{“appium:appActivity”:".ApiDemos",“appium:appPackage”:“io.appium.android.apis”,“appium:deviceName”:“GAlaxy J7 NXT”,“platformName”:“android”,“appium:platformVersion”:“8.1.0”,“appium:udid”:“5200a8764f5ac445”}]}}

[W3C] Calling AppiumDriver.createSession() with args: [{“appActivity”:".ApiDemos",“appPackage”:“io.appium.android.apis”,“platformVersion”:“8.1.0”,“platformName”:“Android”,“udid”:“5200a8764f5ac445”,“deviceName”:“GAlaxy J7 NXT”},null,{“firstMatch”:[{“appium:appActivity”:".ApiDemos",“appium:appPackage”:“io.appium.android.apis”,“appium:deviceName”:“GAlaxy J7 NXT”,“platformName”:“android”,“appium:platformVersion”:“8.1.0”,“appium:udid”:“5200a8764f5ac445”}]}]

[BaseDriver] Event ‘newSessionRequested’ logged at 1560760157403 (13:59:17 GMT+0530 (India Standard Time))

[Appium] DeprecationWarning: ‘automationName’ capability was not provided. Future versions of Appium will require ‘automationName’ capability to be set for Android sessions.

[Appium] Setting automation to ‘UiAutomator1’.

[Appium] Consider setting ‘automationName’ capability to ‘UiAutomator2’ on Android >= 6, since UIAutomator1 framework is not maintained anymore by the OS vendor.

[Appium] Appium v1.12.1 creating new AndroidDriver (v4.11.0) session

[Appium] Capabilities:

[Appium] platformName: android

[Appium] appActivity: .ApiDemos

[Appium] appPackage: io.appium.android.apis

[Appium] deviceName: GAlaxy J7 NXT

[Appium] platformVersion: 8.1.0

[Appium] udid: 5200a8764f5ac445

[BaseDriver] W3C capabilities {“alwaysMatch”:{“platformNa… and MJSONWP desired capabilities {“appActivity”:”.ApiDemos",… were provided

[BaseDriver] Creating session with W3C capabilities: {“alwaysMatch”:{"platformNa…

[BaseDriver] Session created with session id: 980e1fab-b953-4fd3-8a8a-54b5ef84c25c

[ADB] Checking whether adb is present

[ADB] Found 1 ‘build-tools’ folders under ‘C:\Users\Senthil\AppData\Local\Android\Sdk’ (newest first):

[ADB] C:/Users/Senthil/AppData/Local/Android/Sdk/build-tools/28.0.3

[ADB] Using adb.exe from C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe

[AndroidDriver] Retrieving device list

[ADB] Trying to find a connected android device

[ADB] Getting connected devices…

[ADB] 1 device(s) connected

[AndroidDriver] Using device: 5200a8764f5ac445

[ADB] Setting device id to 5200a8764f5ac445

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell getprop ro.build.version.sdk’

[ADB] Current device property ‘ro.build.version.sdk’: 27

[ADB] Device API level: 27

[AndroidDriver] Consider setting ‘automationName’ capability to ‘uiautomator2’ on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.

[AndroidDriver] App file was not listed, instead we’re going to run io.appium.android.apis directly on the device

[AndroidDriver] Checking whether package is present on the device

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell pm list packages io.appium.android.apis’

[AndroidDriver] Starting Android session

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 wait-for-device’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell echo ping’

[AndroidDriver] Pushing settings apk to device…

[ADB] Getting install status for io.appium.settings

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell dumpsys package io.appium.settings’

[ADB] ‘io.appium.settings’ is installed

[ADB] Getting package info for ‘io.appium.settings’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell dumpsys package io.appium.settings’

[ADB] Checking whether aapt is present

[ADB] Using aapt.exe from C:\Users\Senthil\AppData\Local\Android\Sdk\build-tools\28.0.3\aapt.exe

[ADB] The version name of the installed ‘io.appium.settings’ is greater or equal to the application version name (‘2.14.0’ >= ‘2.14.0’)

[ADB] There is no need to install/upgrade ‘C:\Users\Senthil\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’

[ADB] Getting IDs of all ‘io.appium.settings’ processes

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell ‘pgrep --help; echo $?’’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell pgrep -f ^io\.appium\.settings$’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell appops set io.appium.settings android:mock_location allow’

[Logcat] Starting logcat capture

[ADB] Getting device platform version

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell getprop ro.build.version.release’

[ADB] Current device property ‘ro.build.version.release’: 8.1.0

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell wm size’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell getprop ro.product.model’

[ADB] Current device property ‘ro.product.model’: SM-J701F

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell getprop ro.product.manufacturer’

[ADB] Current device property ‘ro.product.manufacturer’: samsung

[AndroidDriver] No app sent in, not parsing package/activity

[AndroidDriver] No app capability. Assuming it is already on the device

[ADB] Getting install status for io.appium.android.apis

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell dumpsys package io.appium.android.apis’

[ADB] ‘io.appium.android.apis’ is installed

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell am force-stop io.appium.android.apis’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell pm clear io.appium.android.apis’

[AndroidDriver] Performed fast reset on the installed ‘io.appium.android.apis’ application (stop and clear)

[AndroidBootstrap] Watching for bootstrap disconnect

[ADB] Forwarding system: 4724 to device: 4724

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 forward tcp:4724 tcp:4724’

[UiAutomator] Starting UiAutomator

[UiAutomator] Moving to state ‘starting’

[UiAutomator] Parsing uiautomator jar

[UiAutomator] Found jar name: ‘AppiumBootstrap.jar’

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 push C:\Users\Senthil\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\bootstrap\bin\AppiumBootstrap.jar /data/local/tmp/’

[ADB] Attempting to kill all uiautomator processes

[ADB] Getting IDs of all ‘uiautomator’ processes

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell pgrep -f ^uiautomator$’

[ADB] No ‘uiautomator’ process has been found

[UiAutomator] Starting UIAutomator

[ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“5200a8764f5ac445”,“shell”,“uiautomator”,“runtest”,“AppiumBootstrap.jar”,"-c",“io.appium.android.bootstrap.Bootstrap”,"-e",“pkg”,“io.appium.android.apis”,"-e",“disableAndroidWatchers”,false,"-e",“acceptSslCerts”,false]

[UiAutomator] Moving to state ‘online’

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.

[AndroidBootstrap] Android bootstrap socket is now connected

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell dumpsys window’

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected

[AndroidDriver] Screen already unlocked, doing nothing

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell am start -W -n io.appium.android.apis/.ApiDemos -S’

[Appium] New AndroidDriver session created successfully, session 980e1fab-b953-4fd3-8a8a-54b5ef84c25c added to master session list

[BaseDriver] Event ‘newSessionStarted’ logged at 1560760177936 (13:59:37 GMT+0530 (India Standard Time))

[W3C (980e1fab)] Cached the protocol value ‘W3C’ for the new session 980e1fab-b953-4fd3-8a8a-54b5ef84c25c

[W3C (980e1fab)] Responding to client with driver.createSession() result: {“capabilities”:{“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“platformName”:“android”,“appActivity”:".ApiDemos",“appPackage”:“io.appium.android.apis”,“deviceName”:“GAlaxy J7 NXT”,“platformVersion”:“8.1.0”,“udid”:“5200a8764f5ac445”},“platformName”:“android”,“appActivity”:".ApiDemos",“appPackage”:“io.appium.android.apis”,“deviceName”:“5200a8764f5ac445”,“platformVersion”:“8.1.0”,“udid”:“5200a8764f5ac445”,“deviceUDID”:“5200a8764f5ac445”,“deviceScreenSize”:“720x1280”,“deviceModel”:“SM-J701F”,“deviceManufacturer”:“samsung”}}

[HTTP] <-- POST /wd/hub/session 200 20554 ms - 746

[HTTP]

[HTTP] --> GET /wd/hub/session/980e1fab-b953-4fd3-8a8a-54b5ef84c25c

[HTTP] {}

[W3C (980e1fab)] Calling AppiumDriver.getSession() with args: [“980e1fab-b953-4fd3-8a8a-54b5ef84c25c”]

[W3C (980e1fab)] Responding to client with driver.getSession() result: {“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“platformName”:“android”,“appActivity”:".ApiDemos",“appPackage”:“io.appium.android.apis”,“deviceName”:“GAlaxy J7 NXT”,“platformVersion”:“8.1.0”,“udid”:“5200a8764f5ac445”},“platformName”:“android”,“appActivity”:".ApiDemos",“appPackage”:“io.appium.android.apis”,“deviceName”:“5200a8764f5ac445”,“platformVersion”:“8.1.0”,“udid”:“5200a8764f5ac445”,“deviceUDID”:“5200a8764f5ac445”,“deviceScreenSize”:“720x1280”,“deviceModel”:“SM-J701F”,“deviceManufacturer”:“samsung”}

[HTTP] <-- GET /wd/hub/session/980e1fab-b953-4fd3-8a8a-54b5ef84c25c 200 127 ms - 678

[HTTP]

[AndroidBootstrap] Emitting alert message…

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message

[BaseDriver] Shutting down because we waited 60 seconds for a command

[AndroidDriver] Shutting down Android driver

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell am force-stop io.appium.android.apis’

[Appium] Closing session, cause was ‘New Command Timeout of 60 seconds expired. Try customizing the timeout using the ‘newCommandTimeout’ desired capability’

[Appium] Removing session 980e1fab-b953-4fd3-8a8a-54b5ef84c25c from our master session list

[ADB] Pressing the HOME button

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell input keyevent 3’

[AndroidBootstrap] Sending command to android: {“cmd”:“shutdown”}

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“shutdown”}

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”}

[AndroidBootstrap] Received command result from bootstrap

[UiAutomator] Shutting down UiAutomator

[UiAutomator] Moving to state ‘stopping’

[UiAutomator] UiAutomator shut down normally

[UiAutomator] Moving to state ‘stopped’

[ADB] Attempting to kill all uiautomator processes

[ADB] Getting IDs of all ‘uiautomator’ processes

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell pgrep -f ^uiautomator$’

[ADB] No ‘uiautomator’ process has been found

[UiAutomator] Moving to state ‘stopped’

[Logcat] Stopping logcat capture

[ADB] Running ‘C:\Users\Senthil\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 5200a8764f5ac445 shell am force-stop io.appium.unlock’

[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.

could you able to find the mistake were i went wrong ?

what is your first code you trying to pass?

This is my first code which i am trying to pass:
package capabilities;

import java.net.MalformedURLException;
import java.net.URL;

//import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
//import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;

public class Test {
//public static void main(String[] args) throws MalformedURLException{

public static AndroidDriver capabilities() throws MalformedURLException {
System.out.println(“Test”);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, “GAlaxy J7 NXT”);
cap.setCapability(“udid”, “5200a8764f5ac445”); //Give Device ID of your mobile phone
cap.setCapability(“platformName”, “Android”);
cap.setCapability(“platformVersion”, “8.1.0”);
cap.setCapability(“appPackage”, “io.appium.android.apis”);
cap.setCapability(“appActivity”,".ApiDemos");
AndroidDriver driver1 = null;
driver1 = new AndroidDriver(new URL(“http://0.0.0.0:4723/wd/hub”),cap);

return driver1;

first code mean code with .click()
in your base1 class.

@Praveena_Arumugam
add one more capability
cap.setCapability(“automationName”,“uiautomator2”);

and use @text

@PramodKarande, if i add that extra cababilities its not running …

@Praveena_Arumugam
what exception you are getting?

Yes, code with class name “Test” means the cababilities set , and the “base1” is for .click()

also try to change this to MobileElement instead of AndroidElement

App opens but could not click the element.

I changed but the same issue is repeating .

Give me some suggestion.

first do this :
fire below commands

adb uninstall io.appium.settings
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
adb uninsatll io.appium.unlock

one by one from your cmd.

then try to run script with automation name as uiautomator2

why should i uninstall, though because of uninstalling all setting may go off right.

appium will install all settings again.

irrespective of response fire above commands.