dlenroc / appium-roku-driver

WebDriver for testing channels / screensavers on roku devices
MIT License
10 stars 0 forks source link

WebDriver Command active doesn't work properly #67

Closed quidow closed 6 months ago

quidow commented 7 months ago

I figured out that this command retrieves one of the elements that have focused="true", according to https://github.com/dlenroc/node-roku/blob/main/packages/dom/src/Document.ts#L21. But I'm not sure, if this an issue of the specific apps that I'm working with, or maybe it's related to another apps as well, but in my case I see several dozen elements with focused="true" at the same time. I also checked Roku WebDriver, its v1/session/:sessionId/element/active returns the actual active element, so I built some workaround that calls Roku WebDriver and matches the received element with the element from the xml tree that I get from the Appium driver. It will be really nice to resolve it somehow just on the driver's side, I can provide any additional information and help if needed.

Screenshot 2023-11-30 at 14 05 29
dlenroc commented 7 months ago

Thank you for the feedback. I plan to enhance this soon but don't have a concrete ETA. I intend to start with the implementation you mentioned, but I need to verify how it will work with ODC context first. Meanwhile, please continue using your solution or some XPath that achieves the same result.

quidow commented 7 months ago

but don't have a concrete ETA

This is completely ok as my workaround works, just want to ultimately make my code cleaner and your driver better :)

dlenroc commented 6 months ago

Hello @quidow, I have aligned the behavior of the active command with the Roku WebDriver in GH-68 and am going to work on this further, as I have found more cases where both are returning the wrong element.

In the meantime, you can try it out using the draft PR above.

quidow commented 6 months ago

Hello @dlenroc, it's cool to see some progress here. I tried to install the driver from the draft PR, but the Appium Server fails to start with this driver installed. My node version is v20.8.0.

quidow@Oleksandrs-MBP ~ % appium driver install --source local /Users/quidow/PycharmProjects/appium-roku-driver-2 ✔ Installing '/Users/quidow/PycharmProjects/appium-roku-driver-2' ℹ Driver roku@0.9.1 successfully installed

  • automationName: roku
  • platformNames: ["roku"]

quidow@Oleksandrs-MBP ~ % appium --allow-cors --base-path /wd/hub --allow-insecure=adb_shell [Appium] Welcome to Appium v2.3.0 (REV c92adb3c479d70bb29f4399a808c972ef41510e7) [Appium] Non-default server args: [Appium] { [Appium] allowCors: true, [Appium] allowInsecure: [ [Appium] 'adb_shell' [Appium] ], [Appium] basePath: '/wd/hub' [Appium] } [Appium] The APPIUM_HOME environment variable: /Users/quidow/.appium [Appium] Attempting to load driver uiautomator2... [Appium] Attempting to load driver xcuitest... [Appium] Attempting to load driver roku... [Appium] Requiring driver at /Users/quidow/PycharmProjects/appium-xcuitest-driver/build/index.js [Appium] Requiring driver at /Users/quidow/PycharmProjects/appium-roku-driver-2/dist/index.js [Appium] Requiring driver at /Users/quidow/.appium/node_modules/appium-uiautomator2-driver/build/index.js [Appium] XCUITestDriver has been successfully loaded in 0.788s [Appium] AndroidUiautomator2Driver has been successfully loaded in 0.788s [Appium] Could not load driver 'roku', so it will not be available. Error in loading the driver was: The module '/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/build/Release/xmljs.node' [Appium] was compiled against a different Node.js version using [Appium] NODE_MODULE_VERSION 120. This version of Node.js requires [Appium] NODE_MODULE_VERSION 115. Please try re-compiling or re-installing [Appium] the module (for instance, using npm rebuild or npm install). [Appium] Error: The module '/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/build/Release/xmljs.node' [Appium] was compiled against a different Node.js version using [Appium] NODE_MODULE_VERSION 120. This version of Node.js requires [Appium] NODE_MODULE_VERSION 115. Please try re-compiling or re-installing [Appium] the module (for instance, using npm rebuild or npm install). [Appium] at Object.Module._extensions..node (node:internal/modules/cjs/loader:1327:18) [Appium] at Module.load (node:internal/modules/cjs/loader:1091:32) [Appium] at Function.Module._load (node:internal/modules/cjs/loader:938:12) [Appium] at Module.require (node:internal/modules/cjs/loader:1115:19) [Appium] at require (node:internal/modules/helpers:130:18) [Appium] at bindings (/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/bindings/bindings.js:112:48) [Appium] at Object. (/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/lib/bindings.js:1:37) [Appium] at Module._compile (node:internal/modules/cjs/loader:1241:14) [Appium] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1295:10) [Appium] at Module.load (node:internal/modules/cjs/loader:1091:32) [Appium] at Function.Module._load (node:internal/modules/cjs/loader:938:12) [Appium] at Module.require (node:internal/modules/cjs/loader:1115:19) [Appium] at require (node:internal/modules/helpers:130:18) [Appium] at Object. (/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/index.js:4:18) [Appium] at Module._compile (node:internal/modules/cjs/loader:1241:14) [Appium] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1295:10) [Appium] at Module.load (node:internal/modules/cjs/loader:1091:32) [Appium] at Function.Module._load (node:internal/modules/cjs/loader:938:12) [Appium] at cjsLoader (node:internal/modules/esm/translators:284:17) [Appium] at ModuleWrap. (node:internal/modules/esm/translators:234:7) [Appium] at ModuleJob.run (node:internal/modules/esm/module_job:217:25) [Appium] at ModuleLoader.import (node:internal/modules/esm/loader:316:24) [Appium] at importModuleDynamicallyWrapper (node:internal/vm/module:431:15) [Appium] at DriverConfig.requireAsync (/Users/quidow/.nvm/versions/node/v20.8.0/lib/node_modules/appium/lib/extension/extension-config.js:596:24) [Appium] at /Users/quidow/.nvm/versions/node/v20.8.0/lib/node_modules/appium/lib/extension/index.js:53:26 uncaughtException: The module '/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/build/Release/xmljs.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 120. This version of Node.js requires NODE_MODULE_VERSION 115. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install). Error: The module '/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/build/Release/xmljs.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 120. This version of Node.js requires NODE_MODULE_VERSION 115. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install). at Object.Module._extensions..node (node:internal/modules/cjs/loader:1327:18) at Module.load (node:internal/modules/cjs/loader:1091:32) at Function.Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at bindings (/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/bindings/bindings.js:112:48) at Object. (/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/lib/bindings.js:1:37) at Module._compile (node:internal/modules/cjs/loader:1241:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Function.Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at Object. (/Users/quidow/PycharmProjects/appium-roku-driver-2/node_modules/roku-dom/node_modules/libxmljs2/index.js:4:18) at Module._compile (node:internal/modules/cjs/loader:1241:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Function.Module._load (node:internal/modules/cjs/loader:938:12) at cjsLoader (node:internal/modules/esm/translators:284:17) at ModuleWrap. (node:internal/modules/esm/translators:234:7) at ModuleJob.run (node:internal/modules/esm/module_job:217:25) at ModuleLoader.import (node:internal/modules/esm/loader:316:24) at importModuleDynamicallyWrapper (node:internal/vm/module:431:15) at DriverConfig.requireAsync (/Users/quidow/.nvm/versions/node/v20.8.0/lib/node_modules/appium/lib/extension/extension-config.js:596:24) at /Users/quidow/.nvm/versions/node/v20.8.0/lib/node_modules/appium/lib/extension/index.js:53:26 [Appium] You have enabled CORS requests from any host. Be careful not to visit sites which could maliciously try to start Appium sessions on your machine [Appium] Appium REST http interface listener started on http://0.0.0.0:4723/wd/hub [Appium] You can provide the following URLs in your client code to connect to this server: [Appium] http://127.0.0.1:4723/wd/hub (only accessible from the same host) [Appium] http://192.168.1.101:4723/wd/hub [Appium] Available drivers: [Appium] - uiautomator2@2.29.11 (automationName 'UiAutomator2') [Appium] - xcuitest@5.11.0 (automationName 'XCUITest') [Appium] - roku@0.9.1 (automationName 'roku') [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. quidow@Oleksandrs-MBP ~ %

quidow commented 6 months ago

I tried both npm rebuild and npm install, but it didn't help.

dlenroc commented 6 months ago

Error you are getting is because the driver was installed/build using Node.js 21 (NODE_MODULE_VERSION 120) and then the appium server was tried to be run with Node.js 20 (NODE_MODULE_VERSION 115) but so far same version had to be used for installation and execution.

Try uninstalling and reinstalling the driver using the same Node.js version.

git clean -fdx
npm ci
appium driver install --source local /Users/quidow/PycharmProjects/appium-roku-driver-2
appium --allow-cors --base-path /wd/hub
quidow commented 6 months ago
git clean -fdx
npm ci
appium driver install --source local /Users/quidow/PycharmProjects/appium-roku-driver-2
appium --allow-cors --base-path /wd/hub

Well, it didn't help me for some reason, but I switched to Node.js 18, reinstalled everything and finally it works.

quidow commented 6 months ago

I ran some tests and can confirm that the driver compiled from the draft PR returns the same active element as the official Roku WebDriver, what's actually pretty cool.

I have found more cases where both are returning the wrong element.

I had to write some workarounds to work with that, but if you'll be able to fix this, it will mean that your driver will work more accurate than the official one, lol

Thanks again for your work! I'll wait until you release a new version.

dlenroc commented 6 months ago

Nice to hear! Could you try it to see if it helps with debugging GH-66? In a future version, I will also get rid of native dependencies so that there are no more NODE_MODULE_VERSION or OS related issues.

quidow commented 6 months ago

Could you try it to see if it helps with debugging GH-66?

We forced to switch the most of people to Linux :) But I'll try to find someone.

dlenroc commented 6 months ago

Active element identification has been aligned with Roku WebDriver in the @dlenroc/appium-roku-driver@0.10.0 release and is going to improve in future.