URI and package arguments are required

I have chrome installed on my android device and adb connected with the device.

then I try to run below testing code on Linux.


const driver = require("webdriverio");

const webopts = {
  path: '/wd/hub',
  port: 4723,
  capabilities: {
    'platformName': "android",
    'appium:platformVersion': "9",
    'appium:browerName': "chrome",
    'appium:showChromedriverLog': true,
    'appium:automationName': "UiAutomator2"
  }
};
async function web() {
  const client = await driver.remote(webopts);
  await client.url("https://appium.io/");
  const title = await client.getTitle();
  await client.deleteSession();
}
web();

and got error below.

[HTTP] --> POST /wd/hub/session/7664d298-2fa4-4242-acb2-93ec1d8cb4fd/url
[HTTP] {"url":"https://appium.io/"}
[debug] [W3C (7664d298)] Calling AppiumDriver.setUrl() with args: ["https://appium.io/","7664d298-2fa4-4242-acb2-93ec1d8cb4fd"]
[debug] [W3C (7664d298)] Encountered internal error running command: Error: URI and package arguments are required
[debug] [W3C (7664d298)]     at ADB.startUri (/home/pan/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:72:11)
[debug] [W3C (7664d298)]     at AndroidUiautomator2Driver.commands.setUrl (/home/pan/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/commands/general.js:202:18)
[debug] [W3C (7664d298)]     at commandExecutor (/home/pan/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:335:9)
[debug] [W3C (7664d298)]     at /home/pan/node_modules/appium/node_modules/async-lock/lib/index.js:146:12
[debug] [W3C (7664d298)]     at AsyncLock._promiseTry (/home/pan/node_modules/appium/node_modules/async-lock/lib/index.js:280:31)
[debug] [W3C (7664d298)]     at exec (/home/pan/node_modules/appium/node_modules/async-lock/lib/index.js:145:9)
[debug] [W3C (7664d298)]     at AsyncLock.acquire (/home/pan/node_modules/appium/node_modules/async-lock/lib/index.js:162:3)
[debug] [W3C (7664d298)]     at AndroidUiautomator2Driver.executeCommand (/home/pan/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:348:39)
[debug] [W3C (7664d298)]     at AppiumDriver.executeCommand (/home/pan/node_modules/appium/lib/appium.js:563:36)
[debug] [W3C (7664d298)]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[debug] [W3C (7664d298)]     at asyncHandler (/home/pan/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:297:21)
[HTTP] <-- POST /wd/hub/session/7664d298-2fa4-4242-acb2-93ec1d8cb4fd/url 500 8 ms - 563
[HTTP] 
[debug] [Instrumentation] The process has exited with code 0
[debug] [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
[Logcat] Logcat terminated with code 0, signal null

It seems it is calling the deep link function but I expect it calls the chrome to navigate to a url on Andriod. I’m using Appium v1.22.3. Any idea what was wrong?

I think you are missing some capabilities. Take a look at this repo of sample tests:

What I’m seeing are the ‘deviceName’ for capabilities, and ‘host’ for server config are missing.

So something like:

const webopts = {
  path: '/wd/hub',
  port: 4723,
  host: 'localhost'
  capabilities: {
    'platformName': "android",
    'appium:platformVersion': "9",
    'appium:deviceName': "My Device Name",
    'appium:browerName': "chrome",
    'appium:showChromedriverLog': true,
    'appium:automationName': "UiAutomator2"
  }
};

I added ‘host’ option and deviceName but got the exact same error.

Maybe copy the way they code? They certainly do a few things differently than your code.

I know what’s wrong in my code. There is a missing ‘s’ in ‘browerName’.

1 Like

you need to provide the following capabilities -
appium:chromedriverExecutable , “abs path to the chromedriver.exe” .
The version of the chromeDriver.exe should be same as the version of the chrome installed in the device

options = new UiAutomator2Options()
.setDeviceName(“XXXXXXX”)
.setPlatformName(“Android”)
.eventTimings();
options.setPlatformVersion(“X”);
options.setCapability(AndroidMobileCapabilityType.BROWSER_NAME,“chrome”);
options.setCapability(“appium:automationName”,“UiAutomator2”);
options.setCapability(“appium:chromedriverExecutable”,“C:\Users\PrashantK\Downloads\chromedriver_win32\chromedriver.exe”);
options.setCapability(MobileCapabilityType.NO_RESET,true);
options.setCapability(“appium:newCommandTimeOut”,10);

			 service = AppiumDriverLocalService.buildService(
					 new AppiumServiceBuilder().withIPAddress("127.0.0.1")
					 .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub").usingPort(4723).withArgument(() -> 
					 "--allow-insecure", "chromedriver_autodownload"));
			service.start();
			driver.set(new AndroidDriver(service,options));									
			}