Error Message: UnknownMethodError: Method is not implemented
Using: selenium-webdriver: ^4.13.0
Appium: 2.0.0
code snippet:
const { Builder, By, Key, until } = require(‘selenium-webdriver’)
const capabilities = {
platformName: ‘Android’,
‘appium:automationName’: ‘UiAutomator2’,
‘appium:deviceName’: ‘Android’,
‘appium:appPackage’: ‘com.android.settings’,
‘appium:appActivity’: ‘.Settings’,
}
async function testRun() {
// //Initiating the Driver
const driver = new Builder().usingServer(“http://127.0.0.1:4723”).withCapabilities(capabilities).forBrowser(’’).build()
const battery = await driver.findElement(By.xpath('//*[@text="Battery"]'))
await driver.sleep(3000)
await battery.click()
await driver.sleep(3000)
const batteryUsage = await driver.findElement(By.xpath('//*[@text="Battery usage"]'))
const result = batteryUsage.isDisplayed()
console.log(result)
await driver.quit();
}
testRun()
Appium error log:
[HTTP] --> POST /session/addb3d2e-bfbe-4f53-ba3e-0ce721b42ffd/execute/sync
[HTTP] {“script”:"/* isDisplayed */return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||“undefined”==typeof c.execScript||c.execScript(“var “+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c[d]&&c[d]!==Object.prototype[d]?c=c[d]:c=c[d]={}:c[d]=b}\nfunction ca(a){var b=typeof a;if(“object”==b)if(a){if(a instanceof Array)return"array”;if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(”[object Window]"==c)return"object";if("[object Array]"==c||“number”==typeof a.length&&“undefined”!=typeof a.splice&&“undefined”!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable(“splice”))return"array";if("[object Function]"==c||“undefined”!=typeof a.call&&“undefined”!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable(“call”))return"function"}else return"null";\nelse if(“function”==b&&“undefined”==typeof a.call)return"object";return b}function da(a,…
[debug] [AndroidUiautomator2Driver@b016 (addb3d2e)] Calling AppiumDriver.execute() with args: ["/* isDisplayed */return (function(){return (function(){var k=this||self;function aa(a){return"string"==typeof a}function ba(a,b){a=a.split(".");var c=k;a[0]in c||“undefined”==typeof c.execScript||c.execScript(“var “+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c[d]&&c[d]!==Object.prototype[d]?c=c[d]:c=c[d]={}:c[d]=b}\nfunction ca(a){var b=typeof a;if(“object”==b)if(a){if(a instanceof Array)return"array”;if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(”[object Window]"==c)return"object";if("[object Array]"==c||“number”==typeof a.length&&“undefined”!=typeof a.splice&&“undefined”!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable(“splice”))return"array";if("[object Function]"==c||“undefined”!=typeof a.call&&“undefined”!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable(“call”))return"function"}else return"null";\nelse if(“function”==b&&“undefined”==typeof a.call)return"object";return b}function da(a,b,c){retu…
[debug] [AndroidUiautomator2Driver@b016 (addb3d2e)] Encountered internal error running command: NotImplementedError: Method is not implemented