Inconsistency in Appium Test Case Execution(Android Platform)

Hi All,
I am new to this Group and beginner for Appium Tool, faced below Issues :

Test details :
Application : Android
Appium Version : 1.9.1
Android Studio Version : 4.1
android phone Version : 9

Issue 1 ) observed Appium Inspector crash when running multiple test cases and crash is inconsistent.
ex: sometime crash happen on 5th test case and sometime 8th test case with same code without change in code.

Issue 2 ) simple test case executed fine in 1 phone not working in another phone

Issue 3 ) observed ADB disconnect during test under execution.

please find the attached issue details .

Ph no : +91 9986276954

do not use Appium GUI for tests. start Appium server in command line.

1 Like

Thank you Aleksei for the suggestion.
i tried to start the server using command line by refering the below link but got some error,
please suggest to on how to run by command line…do i need to install any other tools…please guide.

attached the reference Image.

first install npm on windows ->
second install Appium server using npm command:

npm install -g appium

now you should be able start Appium server with ‘appium’ command in command prompt in any folder. you will not need navigate anywhere.

1 Like

Hi Aleksei,
I am able to run the Test case without crash with your suggestions above.
Earlier spent lot of time debugging the crash issue. Big Big Thank you,

currently facing 1 Issue related to Server. some time the click event on button not work
ex: click on id:button2 not worked shows visibility not found.

please guide.

error_log.txt (136.2 KB)

I see only

“An element could not be located on the page using the given search parameters.”

1 Like

Hi Aleksei,
Observed whenever Test case Failed, when re test is done, then basic click function not working,
Even after restarting the server and uninstalled the Appium Settings installed in the phone the issue repeatedly coming.
Have you faced such issues in Appium…?

attached the LOG for reference

please guide me…

error_log1.txt (129.1 KB)

I use command line appium server and pageObject model for searching elements. Above issue did not observe.

possible problem in code. provide example how you find element

1 Like

Thank you Aleksei For the Quick Response.
I have mentioned below my sample script :

    MobileElement el2 = (MobileElement) driver.findElementByAccessibilityId("Open navigation drawer");; 

when i start the Appium Server and run the Code its detect some time and some time not
observed inconsistent behavior.

below things i tried but still issue not solved :

1 ) Terminated the Server and restarted.
2 ) uninstalled the Appium Settings which was installed in previous test

getting below Message :

    MobileElement el2 = (MobileElement) driver.findElementByAccessibilityId("Open navigation drawer");; 

My doubt is without changing the code same script works perfectly Fine some other time!

Can we have further discussion over google Meet so that i can show my desktop and explain the problem, Kindly let me know

below my details :

my mail id : [email protected]
Location : India
WhatsApp and Ph no : +91 9986276954

Thanks and regards

Try to increase wait time (see implicit example) or try switch to wait example.
Read more:

Hi Aleksei,
used all types of wait function as suggested by you in above link including implicit wait before the App drawer Click Functrion as below

try {
} catch (InterruptedException e) {

    System.out.println("END :" + driver.currentActivity());

    MobileElement el11 = (MobileElement) driver.findElementByAccessibilityId("Open navigation drawer");;

still faced below Issue

[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [WD Proxy] Matched ‘/element’ to command name ‘findElement’
[debug] [WD Proxy] Proxying [POST /element] to [POST] with body: {“strategy”:“xpath”,“selector”:“/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.FrameLayout/androidx.recyclerview.widget.RecyclerView/androidx.appcompat.widget.LinearLayoutCompat[4]/android.widget.CheckedTextView”,“context”:“”,“multiple”:false}
[WD Proxy] Got response with status 404: {“sessionId”:“65344b1d-13aa-4631-bbe1-e8028927b53e”,“value”:{“error”:“no such element”,“message”:“An element could not be located on the page using the given search parameters”,“stacktrace”:"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(\n\tat\n\tat…
[debug] [W3C] Matched W3C error code ‘no such element’ to NoSuchElementError
[debug] [W3C (cbe59fa4)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
[debug] [W3C (cbe59fa4)] at AndroidUiautomator2Driver.findElOrEls (C:\Users\nanoPix\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
[debug] [W3C (cbe59fa4)] at runMicrotasks ()
[debug] [W3C (cbe59fa4)] at processTicksAndRejections (internal/process/task_queues.js:95:5)
[debug] [W3C (cbe59fa4)] at AndroidUiautomator2Driver.findElOrElsWithProcessing (C:\Users\nanoPix\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\find.js:33:12)
[debug] [W3C (cbe59fa4)] at AndroidUiautomator2Driver.findElement (C:\Users\nanoPix\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\basedriver\commands\find.js:53:10)
[HTTP] ← POST /wd/hub/session/cbe59fa4-0214-4241-8fbe-ae2802650f5c/element 404 166 ms - 920

Looks my issue somewhat similar to the below Issue

thanks and regards

i see problem in fail to find above large xpath. better avoid using such long locators and better avoid using xpath.

Hi Aleksei,
I am using the Xpath which is Auto Generated by the Appium Tool. I did not find any way to shorten the Xpath. Kindly suggest how to shorten the Xpath.

Also, As you have suggested avoid Xpath, guide me the other ways by which I can locate the Controls created in our App.

Share page source and element you need

Hi Aleksei,
Thank you for your speedy response. Currently, I do not have access to the source code. I need a couple of days time to arrange the same. Meanwhile, share with me the best practices to set shorter Xpath and Alternate ways by which we can avoid Xpath.

Not app code but page source of screen where we see elements.

Print output of driver.getPageSource() on needed screen.