AppiumDriver.execute() with args is not working on real iOS device

Hi All,
We are upgrading our framework from selenium 3.x.x to 4.16.1 and update the Appium Java Client 9.0.0.

Our JS script with excecuteScript() method is working fine before upgrading but now it throws an error like:

Encountered internal error running command: NotImplementedError: Method is not implemented
[debug] [W3C (400eb395)] at XCUITestDriver.execute

-Also CSS selector is not working on real device.

Below are the version details on which we are trying to run or js script to login into device :

Appium : 2.0.1
iOS Version : 14.6, 16.6 and 17.2
Selenium Version : 4.16.1
Appium Java Client Version : 9.0.0

we are using below capabilities to run our test on device :

DesiredCapabilities capabilities = new DesiredCapabilities(); **
** capabilities.setCapability(CapabilityType.PLATFORM_NAME, m_platform.name());

** capabilities.setCapability(BaseOptions.PLATFORM_VERSION_OPTION, m_platformVersion);**
** capabilities.setCapability(SupportsDeviceNameOption.DEVICE_NAME_OPTION, m_deviceName);**
** capabilities.setCapability(CapabilityType.BROWSER_NAME, EMPTY_STRING); **
** capabilities.setCapability(SupportsAppOption.APP_OPTION, m_appPath);**
** capabilities.setCapability(SupportsUdidOption.UDID_OPTION, m_deviceId);**
** capabilities.setCapability(BaseOptions.NEW_COMMAND_TIMEOUT_OPTION, NEW_COMMAND_TIMEOUT);**
** capabilities.setCapability(“appium:chromeOptions”, ImmutableMap.of(“w3c”, false));**
capabilities.setCapability(XCUITestOptions.AUTO_ACCEPT_ALERTS_OPTION, true);
** capabilities.setCapability(BaseOptions.AUTOMATION_NAME_OPTION, “XCUITest”);**

also we have tried by below xcuitest oprions :

XCUITestOptions xcuiTestOptions = new XCUITestOptions()

** .setDeviceName(“iPad (7th generation)”)**

** .setPlatformVersion(“16.6”)**

** .setApp("/Users/admin/Desktop/IPA/XYZ.app")**

** .setUdid(“xxxxxxx”)**

** .setAutoAcceptAlerts(true)**

** .setAutomationName(“XCUITest”)**

** .setWdaLocalPort(xxxx);**

m_driver = new IOSDriver(new URL("
http://123.456.789.44:4794/")
, xcuiTestOptions);

setStartAddress(address);

Still it is not working so I tried with some of the thread that we need execute driver Plugin
I have tried it also and run the port through terminal using below command :

appium -p 4799 --default-capabilities ‘{“appium:wdaLocalPort”:xx,“appium:udid”:“xxxxx”}’ --use-plugins=execute-driver --allow-insecure=execute_driver_script

but still it doesn’t work.

@mykola-mokhnach and @Aleksei Below are the Appium server logs for the same Please review it and do needful is there something that we missing in this :

Calling AppiumDriver.execute() with args: ["$(function(){ $(’.js-code’).val(’ https://xyz/’); :wink: $(’.js-starthost’).click();})",[],“400eb395-37d5-4878-add7-e8b6c8ae72e7”]
[debug] [XCUITest] Executing command 'execute’
[debug] [W3C (400eb395)] Encountered internal error running command: NotImplementedError: Method is not implemented
[debug] [W3C (400eb395)] at XCUITestDriver.execute (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/execute.js:38:11)
[debug] [W3C (400eb395)] at commandExecutor (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:335:9)
[debug] [W3C (400eb395)] at /usr/local/lib/node_modules/appium/node_modules/async-lock/lib/index.js:146:12
[debug] [W3C (400eb395)] at AsyncLock._promiseTry (/usr/local/lib/node_modules/appium/node_modules/async-lock/lib/index.js:280:31)
[debug] [W3C (400eb395)] at exec (/usr/local/lib/node_modules/appium/node_modules/async-lock/lib/index.js:145:9)
[debug] [W3C (400eb395)] at AsyncLock.acquire (/usr/local/lib/node_modules/appium/node_modules/async-lock/lib/index.js:162:3)
[debug] [W3C (400eb395)] at XCUITestDriver.executeCommand (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:348:39)
[debug] [W3C (400eb395)] at XCUITestDriver.executeCommand (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:786:24)
[debug] [W3C (400eb395)] at AppiumDriver.executeCommand (/usr/local/lib/node_modules/appium/lib/appium.js:563:36)
[debug] [W3C (400eb395)] at runMicrotasks ()
[debug] [W3C (400eb395)] at processTicksAndRejections (internal/process/task_queues.js:95:5)
[debug] [W3C (400eb395)] at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:297:21)
[HTTP] <-- POST /wd/hub/session/400eb395-37d5-4878-add7-e8b6c8ae72e7/execute/sync 405 6 ms - 1387
[HTTP]
[HTTP] --> GET /wd/hub/session/400eb395-37d5-4878-add7-e8b6c8ae72e7/window/handles
[HTTP] {}
[debug] [W3C (400eb395) ] Calling AppiumDriver.getWindowHandles() with args: [“400eb395-37d5-4878-add7-e8b6c8ae72e7”]
[debug] [XCUITest] Executing command 'getWindowHandles’
[debug] [W3C (400eb395)] Encountered internal error running command: NotImplementedError: Method is not implemented
[debug] [W3C (400eb395)] at XCUITestDriver.getWindowHandles (

Calling AppiumDriver.execute() with args: ["$(function(){ $(’.js-code’).val(’
https://xyz.pqr/’);
$(’.js-starthost’).click();})",[],“400eb395-37d5-4878-add7-e8b6c8ae72e7”]

[debug] [XCUITest] Executing command ‘execute’

[debug] [W3C (400eb395)] Encountered internal error running command: NotImplementedError: Method is not implemented

Calling AppiumDriver.execute() with args: ["$(function(){ $(’.js-code’).val('
https://xyz.com/pqr/’);
** $(’.js-starthost’).click();})",[],“400eb395-37d5-4878-add7-e8b6c8ae72e7”]**

[debug] [XCUITest] Executing command 'execute’

[debug] [W3C (400eb395)] Encountered internal error running command: NotImplementedError: Method is not implemented

Regards,
Krushant

Any update on this ? @mykola-mokhnach

I assume you are trying to execute web APIs inside a native context. Then above errors are expected

Hi @mykola-mokhnach we are not using web API we are using the Appium’s execute method to execute Appium execute command

it is working on the below versions :

org.seleniumhq.selenium selenium-java 3.141.59 io.appium java-client 7.2.0

But not working on below versions :

org.seleniumhq.selenium selenium-java 4.16.1 io.appium java-client 9.0.0

if you have some work around regrading this could you please provide for the same ?

Thanks and Regards,
Krushant

Hi @mykola-mokhnach we are not using web API we are using the Appium’s execute method to execute Appium execute command

I am confused. All the above commands from the logs ("$(function(){ $(’.js-code’).val(’ https://xyz/’); :wink: $(’.js-starthost’).click();}), getWindowHandles()) don’t make any sense in native context. They are only applicable to the web context.