question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FindElements works locally but not on my server

See original GitHub issue

The problem

Hi guys,

I have installed Appium and Android Studio on my PC and server. On the server side, I launch the emulator without graphical interface <my-path-to-emulator>/emulator -avd Pixel_4_API_30_Google_API -no-window -no-skin -no-audio -no-snapshot-load

Once my emulator is launched, I type node index.js to launch my script

Locally, findElements gives me a list of elements

2022-06-02T14:11:40.818Z INFO webdriver: COMMAND findElementsFromElement("00000000-0000-0008-ffff-ffff000000e2", "id", "cl_category_row")
2022-06-02T14:11:40.820Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session/5c981908-cbd4-4e8b-9b11-98ab82b252df/element/00000000-0000-0008-ffff-ffff000000e2/elements
2022-06-02T14:11:40.820Z INFO webdriver: DATA { using: 'id', value: 'cl_category_row' }
2022-06-02T14:11:40.857Z INFO webdriver: RESULT [
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000e3',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000e3'
  },
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000e7',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000e7'
  },
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000eb',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000eb'
  },
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000ef',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000ef'
  },
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000f3',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000f3'
  },
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000f7',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000f7'
  },
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000fb',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000fb'
  },
  {
    'element-6066-11e4-a52e-4f735466cecf': '00000000-0000-0008-ffff-ffff000000ff',
    ELEMENT: '00000000-0000-0008-ffff-ffff000000ff'
  }
]

However, on my server, it gives me an empty list:

2022-06-02T14:43:03.002Z INFO webdriver: COMMAND findElementsFromElement("00000000-0000-0008-ffff-ffff0000003c", "id", "cl_category_row")
2022-06-02T14:43:03.003Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session/1462332c-a204-4436-94d1-3a267c38025c/element/00000000-0000-0008-ffff-ffff0000003c/elements
**2022-06-02T14:43:03.003Z INFO webdriver: DATA { using: 'id', value: 'cl_category_row' }
2022-06-02T14:43:03.034Z INFO webdriver: RESULT []

I don’t undestand why it gives me nothing on my server

Environment

  • Appium version (or git revision) that exhibits the issue: 1.22.3
  • Desktop OS/version used to run Appium: Linux/Debian Server
  • Node.js version (unless using Appium.app|exe): Server: v16.13.2 and PC: v12.22.9
  • Package manager name and version (we only officially support NPM): NPM (Server: 8.1.2 and PC: 8.5.1)
  • Mobile platform/version under test: On PC and server: Pixel 4 API 30 Android 11.0
  • Real device or emulator/simulator: Emulator
  • webdriverio: 7.19.7

Code

To find Elements:

var recyclerView = await client.$('id=rv_categories');
await recyclerView.waitForExist({
        timeout: 5000,
        timeoutMsg: 'Timeout after 5s'
});
var categories = await recyclerView.$$('id=cl_category_row'); // Locally, gives me a list of elements but on server nothing

Link to Appium logs

pc_appium_logs.txt server_appium_logs.txt

Please help !

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
AZagatticommented, Jun 3, 2022

We are also having problems testing our applications, in this case the id exists in the element but when trying to locate it it doesn’t work, even locally, looking at the logs, a 404 is returned when using the Inspector’s Get Timing. Does it have anything to do with this issue?

Log:

[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8200/wd/hub/session/58bd5d64-a398-474c-a042-5db4fcc35be9/element] with body: {"strategy":"xpath","selector":"//android.view.View[@content-desc=\"onboarding-secondary-action-button\"]","context":"","multiple":false}
[WD Proxy] Got response with status 200: {"sessionId":"58bd5d64-a398-474c-a042-5db4fcc35be9","value":{"ELEMENT":"00000000-0000-009e-ffff-ffff00000028","element-6066-11e4-a52e-4f735466cecf":"00000000-0000-009e-ffff-ffff00000028"}}
[W3C (a18ae922)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"00000000-0000-009e-ffff-ffff00000028","ELEMENT":"00000000-0000-009e-ffff-ffff00000028"}
[HTTP] <-- POST /wd/hub/session/a18ae922-e3b2-494b-bce4-8cf469b0bf80/element 200 56 ms - 137
[HTTP] 
[HTTP] --> POST /wd/hub/session/a18ae922-e3b2-494b-bce4-8cf469b0bf80/element
[HTTP] {"using":"accessibility id","value":"onboarding-secondary-action-button"}
[W3C (a18ae922)] Calling AppiumDriver.findElement() with args: ["accessibility id","onboarding-secondary-action-button","a18ae922-e3b2-494b-bce4-8cf469b0bf80"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8200/wd/hub/session/58bd5d64-a398-474c-a042-5db4fcc35be9/element] with body: {"strategy":"accessibility id","selector":"onboarding-secondary-action-button","context":"","multiple":false}
[WD Proxy] Got response with status 200: {"sessionId":"58bd5d64-a398-474c-a042-5db4fcc35be9","value":{"ELEMENT":"00000000-0000-009e-ffff-ffff00000028","element-6066-11e4-a52e-4f735466cecf":"00000000-0000-009e-ffff-ffff00000028"}}
[W3C (a18ae922)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"00000000-0000-009e-ffff-ffff00000028","ELEMENT":"00000000-0000-009e-ffff-ffff00000028"}
[HTTP] <-- POST /wd/hub/session/a18ae922-e3b2-494b-bce4-8cf469b0bf80/element 200 22 ms - 137
[HTTP] 
[HTTP] --> POST /wd/hub/session/a18ae922-e3b2-494b-bce4-8cf469b0bf80/element
[HTTP] {"using":"id","value":"onboarding-secondary-action-button"}
[W3C (a18ae922)] Calling AppiumDriver.findElement() with args: ["id","onboarding-secondary-action-button","a18ae922-e3b2-494b-bce4-8cf469b0bf80"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8200/wd/hub/session/58bd5d64-a398-474c-a042-5db4fcc35be9/element] with body: {"strategy":"id","selector":"onboarding-secondary-action-button","context":"","multiple":false}
[WD Proxy] Got response with status 404: {"sessionId":"58bd5d64-a398-474c-a042-5db4fcc35be9","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.safeHandle(FindElement.java:70)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:266)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:260)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.chann...
[W3C] Matched W3C error code 'no such element' to NoSuchElementError
[W3C (a18ae922)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
[W3C (a18ae922)]     at AndroidUiautomator2Driver.findElOrEls (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-android-driver/lib/commands/find.js:75:11)
[W3C (a18ae922)]     at runMicrotasks ()
[W3C (a18ae922)]     at processTicksAndRejections (internal/process/task_queues.js:97:5)
[W3C (a18ae922)]     at AndroidUiautomator2Driver.findElOrElsWithProcessing (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:33:12)
[W3C (a18ae922)]     at AndroidUiautomator2Driver.findElement (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:53:10)
[HTTP] <-- POST /wd/hub/session/a18ae922-e3b2-494b-bce4-8cf469b0bf80/element 404 22 ms - 948
[HTTP] 
[HTTP] --> GET /wd/hub/session/a18ae922-e3b2-494b-bce4-8cf469b0bf80/timeouts
[HTTP] {}
[W3C (a18ae922)] Calling AppiumDriver.getTimeouts() with args: ["a18ae922-e3b2-494b-bce4-8cf469b0bf80"]
[W3C (a18ae922)] Responding to client with driver.getTimeouts() result: {"command":3600000,"implicit":0}

Get Timing without ms to id:

image

Testing with a new app only with routes, button and testID:

image

0reactions
mykola-mokhnachcommented, Jun 6, 2022

Closed as resolved

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Selenium can find element when run locally but can't ...
Basically, Selenium is finding the element fine when I run the code locally, but when the code is run on a Heroku server,...
Read more >
Element not found in a runtime - SQA Stack Exchange
One more thing you can try use findElements instead of findElement, findElements will return an empty list if no matching element is found...
Read more >
findElement vs findElements in Selenium - BrowserStack
The findElements command returns an empty list if no elements are found using the given locator strategy and locator value.
Read more >
[Code example]-Why Selenium Server didn't find locator
Why is Selenium unable to find elements on some sites? Why is selenium find element not working? Why can't selenium find XPath even...
Read more >
How to solve Element is not clickable at point in Selenium
It mostly happens in Chrome so if you are mostly working with Firefox or IE then you will not be getting this exception....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found