The URL '/session' did not map to a valid resource | How to run desktop application test using winAppDriver / windows application driver using java?

After long research, I have found the answer for the above question. We can solve this using two methods.

NOTE: You should start either appium server or winappdriver.exe. Don't try to run both appium and winappdriver at once by your self.

  1. If you are starting appium server, you should give the URI as well as below following by the IP and port;

    CalculatorSession = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

  2. If you are running the winappdriver.exe directly, you should give only the IP and the port of winappdriver as below;

    CalculatorSession = new IOSDriver(new URL("http://127.0.0.1:4723"), capabilities);


Thanks @Vijendran Selvarajah at first.

for this example:http://appium.io/docs/en/about-appium/getting-started/ need add this line path: "/wd/hub"

// javascript

const wdio = require("webdriverio");
const assert = require("assert");

const opts = {
  port: 4723,
  path: "/wd/hub", // fix: The URL '/session' did not map to a valid resource
  capabilities: {
    platformName: "Android",
    platformVersion: "8",
    deviceName: "Android Emulator",
    app: "/path/to/the/downloaded/ApiDemos.apk",
    appPackage: "io.appium.android.apis",
    appActivity: ".view.TextFields",
    automationName: "UiAutomator2"
  }
};

async function main () {
  const client = await wdio.remote(opts);

  const field = await client.$("android.widget.EditText");
  await field.setValue("Hello World!");
  const value = await field.getText();
  assert.equal(value,"Hello World!");

  await client.deleteSession();
}

main();

I will share a completed doc and zip in the feature about how to use Appium to test Android App with all deps.