Not able to clcik my elements in apppium program


#1

This is my code
Public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub

	AndroidDriver <AndroidElement> driver=Capabilities();
	
	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS );
	driver.findElementByXPath("//android.widget.TextView[@text='Preference']").click();

When i ran this program only application is launching. After that no action is performed

info: --> POST /wd/hub/session {“capabilities”:[{“desiredCapabilities”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”}},{“requiredCapabilities”:{}}],“desiredCapabilities”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”},“requiredCapabilities”:{}}
info: Client User-Agent string: Apache-HttpClient/4.5.3 (Java/1.8.0_131)
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk
info: [debug] Creating new appium session 79254898-58e3-4c4c-ab62-c6280f74a5b6
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_77
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe dump badging C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk
info: [debug] badging package: io.appium.android.apis
info: [debug] badging act: io.appium.android.apis.ApiDemos
info: [debug] Parsed package and activity are: io.appium.android.apis/io.appium.android.apis.ApiDemos
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\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 9b56dc7f0603
info: [debug] Setting device id to 9b56dc7f0603
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 wait-for-device
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 23
info: Device API level is: 23
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “getprop persist.sys.language”
info: [debug] Current device persist.sys.language:
info: [debug] java -jar “C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar” “stringsFromApk” “C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk” “C:\Users\Sachin\AppData\Local\Temp\io.appium.android.apis”
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 push “C:\Users\Sachin\AppData\Local\Temp\io.appium.android.apis\strings.json” /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe dump xmltree C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk AndroidManifest.xml
info: [debug] Set app process to: io.appium.android.apis
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk.
info: [debug] executing cmd: java -jar “C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar” C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\zipalign.exe -f 4 C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk C:\Users\Sachin\AppData\Local\Temp\11751-2328-hb7gu3\appium.tmp
info: [debug] MD5 for app is 29649242b53e9a67ba855b067422713c
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “ls /data/local/tmp/29649242b53e9a67ba855b067422713c.apk”
info: [debug] Getting install status for io.appium.android.apis
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 23
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “pm list packages -3 io.appium.android.apis”
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\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “am force-stop io.appium.android.apis”
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “pm clear io.appium.android.apis”
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 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\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 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\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 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\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg io.appium.android.apis -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] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
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] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “dumpsys window”
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
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”:“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: {“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] Getting device API level
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “getprop ro.build.version.sdk”
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:false}
info: [debug] Device is at API Level 23
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.android.apis/io.appium.android.apis.ApiDemos”
info: [debug] Waiting for pkg “io.appium.android.apis” and activity “io.appium.android.apis.ApiDemos” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “dumpsys window windows”
info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell “getprop ro.build.version.release”
info: [debug] Device is at release version 6.0.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 79254898-58e3-4c4c-ab62-c6280f74a5b6
info: <-- POST /wd/hub/session 303 35022.813 ms - 74
info: --> GET /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”},“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“9b56dc7f0603”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: <-- GET /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6 200 2.179 ms - 573 {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”},“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“9b56dc7f0603”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: --> GET /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”},“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“9b56dc7f0603”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: <-- GET /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6 200 4.386 ms - 573 {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”},“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“9b56dc7f0603”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: --> GET /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”},“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“9b56dc7f0603”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: <-- GET /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6 200 8.535 ms - 573 {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformVersion”:“6.0.1”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“sachin”},“app”:“C:\Users\Sachin\workspace\Tutorial\src\ApiDemos-debug.apk”,“platformName”:“Android”,“deviceName”:“9b56dc7f0603”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: --> POST /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6/timeouts {“type”:“implicit”,“ms”:10000}
info: [debug] Set Android implicit wait to 10000ms
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: <-- POST /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6/timeouts 200 2.504 ms - 76 {“status”:0,“value”:null,“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: --> POST /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6/element {“using”:“xpath”,“value”:"//android.widget.TextView[@text=‘Preference’]"}
info: [debug] Waiting up to 10000ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:"//android.widget.TextView[@text=‘Preference’]",“context”:"",“multiple”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.TextView[@text=‘Preference’]",“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 //android.widget.TextView[@text=‘Preference’] using XPATH with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.TextView, INSTANCE=9]
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:{“ELEMENT”:“1”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: <-- POST /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6/element 200 410.550 ms - 87 {“status”:0,“value”:{“ELEMENT”:“1”},“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: --> POST /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6/element/1/click {“id”:“1”}
info: [debug] Pushing command to appium work queue: [“element:click”,{“elementId”:“1”}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:click”,“params”:{“elementId”:“1”}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}
info: <-- POST /wd/hub/session/79254898-58e3-4c4c-ab62-c6280f74a5b6/element/1/click 200 40.339 ms - 76 {“status”:0,“value”:true,“sessionId”:“79254898-58e3-4c4c-ab62-c6280f74a5b6”}


#2

@sachi041 give a try:

String text = "Preference";
Mobile el = driver.findElement(MobileBy
                        .AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("
                                + "new UiSelector().text(\"" + text + "\"));")));
new TouchAction((MobileDriver) driver).press(el).waitAction(Duration.ofMillis(70)).release().perform();

#3

Hi Aleksei Thanks for the reply. Is there any mistake in my code ? and I am beginner and you are code looks bit complex to me.


#4

NOT correct. correct is something like “//android.widget.TextView[text()=“Preference”]” BUT better use mine - it does automatic swipe to needed element when it outside screen.


#5

You can also try the following locators…

By.id("text1") // If it's unique

or

MobileBy.AccessibilityId("Preference") // matches content-desc

Aleksei, does that UiScrollable work for UIAutomator2 also?


#6

@sachi041 are you able to resolve the question you asked? I am newbie too and started automation 2 days back. I am also facing the same issue. Could you please share the resolution with me too? or @Brian_Watson any help from you is also highly appreciated. thanks.


#7

@Aleksei any guidance from your side knowing that I have also the same code as shared by @sachi041 in the very first post.


#8

@Waqas_Ahmed any problem with code i gave? Just did not get your problem…


#9

@Aleksei thanks for the reply:
I didn’t get your code since it looked difficult to me.
I’m writing this code and purpose is to click on a button which takes the user to next screen. Upon tapping that button it takes to other screen. For now, as I run the App, the App starts but the automatic taps don’t happen. in Udemy tutorial same code works but not for me.

	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	//to click on specific object/position on a screen
	driver.findElementByXPath("//android.widget.TextView[text()='Preference']").click();
	driver.findElementByXPath("//android.widget.TextView[text()='3. Preference dependencies']").click();
	//finding element by ID
	driver.findElementById("android:id/checkbox").click();
	// 
	driver.findElementByXPath("//android.widget.RelativeLayout)[2]").click();

#10

@Waqas_Ahmed mine code helps for Android to scroll lists and find needed text. If it is your case - use it. For simple tap use any working for you.

It is hard to say what does not work for you without screenshot and page source.


#11

@Aleksei Hello,
I have a very similar issue. The appium inspector give me the following xpath, (resourceid is null value in this element). This app is an android app made by flutter.
Appium inspector:

MobileElement el2 = (MobileElement) driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View[7]/android.view.View[4]");
el2.click();

I used several xpath without to get perform click on this element (by text, etc…)
//driver.findElementByXPath("//android.view.View[7]/android.view.View[4]").click();
//driver.findElementByXPath("//android.view.View[contains(@text, ‘Información’)]").click();

Can you help me about this, please?
Thank you in advance!


#12

try

String text = "your_text";
        driver.findElement(MobileBy
                .AndroidUIAutomator("new UiSelector().text(\""+text+"\")"));

#13

Unfortunately, it doesn’t work. Error is displayed because the element isn’t located.
Exception in thread “main” org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.

The code is the following:
import java.util.concurrent.TimeUnit;

import io.appium.java_client.MobileBy;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

public class home extends base {

	public static void main(String[] args) throws MalformedURLException, InterruptedException {
		// TODO Auto-generated method stub
				AndroidDriver<AndroidElement> driver=Capabilities();
				driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
				driver.findElementById("com.android.packageinstaller:id/permission_allow_button").click();
				//driver.findElementByXPath("//android.view.View[@instance=4]").click();
				//driver.findElementByXPath("//android.widget.Button[@index=1]").click();
				Thread.sleep(5000);
		  String text = "Log In";
		  driver.findElement(MobileBy
		  .AndroidUIAutomator("new UiSelector().text(\""+text+"\")")).click();
		 
	}

}

#14

your text contains diatonic. it may look differently. not as you see. try 100% latin.


#15

@fer try CONTAINS! mine example was when text equals.

String text = "your_text";
        driver.findElement(MobileBy
                .AndroidUIAutomator("new UiSelector().textContains(\""+text+"\")"));

#16

It doesn’t work textContains too. The element is not found. This app is made by “flutter”. I don’t now it is the problem.
Appium inspetor recognizes this item “Log In”.

String text = “Log In”; driver.findElement(MobileBy
.AndroidUIAutomator(“new UiSelector().textContains(”"+text+"")")).click();


#17

@Aleksei
Finally, I got to perform click on this element with that sentence in flutter apk :slight_smile:
The problem was another related with the setup when the apk is installed.
Thank you.