After updating Appium to the newer version Appium 1.22.3 I am getting a status 404 error when trying to launch Appium programmatically.
It used to work fine in the older version but now I am kind of not sure why I am getting this error.
public void globalSetup(ITestContext context) throws Exception {
// Load Props
loadProperties("appiumTests.properties");
// Load Secrets, Create the file
loadSecrets(System.getProperty("user.home") + "/automationSecrets.properties");
// Get Suite name
prop.setProperty("SuiteName", context.getName());
if (getRestartDeviceProperty().equals("true")) {
DeviceInteractions.rebootDevice(getPlatformData(), getDeviceUdidData(getDeviceNameData()));
}
logger.info("Building Appium Server...");
AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
.withArgument(GeneralServerFlag.LOG_LEVEL, "info").withArgument(GeneralServerFlag.RELAXED_SECURITY)
.withLogFile(new File(System.getProperty("user.dir") + "/logs/appium.log")).usingAnyFreePort();
service = builder.build();
logger.info("The url is" +service);
logger.info("Appium server is built.");
logger.info("Starting appium server...");
service.start();
logger.info("Appium server started.");
cleanFileContent("report.txt");
// Clean TestID file
prop.setProperty(testRailRunIDProp, "");
}
public URL getServiceUrl() {
return service.getUrl();
}
And in the set up I am calling the driver like this.
driver = new AndroidDriver(getServiceUrl(), capabilities);
Error that I am getting
[ DEBUG] 2024-05-21 18:07:31.339 [org.testng.log4testng.Logger.debug(Logger.java:82)] – suiteXmlPath: “/Users/subh/Library/Caches/JetBrains/IdeaIC2024.1/temp-testng-customsuite.xml”
[ INFO ] 2024-05-21 18:07:32.075 [org.testng.log4testng.Logger.info(Logger.java:112)] – [TestNG] Running:
/Users/subh/Library/Caches/JetBrains/IdeaIC2024.1/temp-testng-customsuite.xml
[ INFO ] 2024-05-21 18:07:32.144 [TestHelpers.PropertiesHelper.getRestartDeviceProperty(PropertiesHelper.java:207)] – Loading the ‘RestartDevice’ Property from the ‘appiumTests.properties’ file
[ INFO ] 2024-05-21 18:07:32.144 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:93)] – Building Appium Server…
[ INFO ] 2024-05-21 18:07:32.245 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:100)] – The url isio.appium.java_client.service.local.AppiumDriverLocalService@45c80312
[ INFO ] 2024-05-21 18:07:32.245 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:101)] – Appium server is built.
[ INFO ] 2024-05-21 18:07:32.245 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:102)] – Starting appium server…
[Appium] Welcome to Appium v1.22.3
[Appium] Non-default server args:
[Appium] port: 16292
[Appium] logFile: /Users/subh/IdeaProjects/tile_mobile_automation/logs/appium.log
[Appium] loglevel: info
[Appium] relaxedSecurityEnabled: true
[Appium] Appium REST http interface listener started on 0.0.0.0:16292
[HTTP] –> GET /status
[HTTP] {}
[HTTP] <– GET /status 404 13 ms – 211
[HTTP]
[HTTP] –> GET /status
[HTTP] {}
[HTTP] <– GET /status 404 9 ms – 211
[HTTP]
The issue likely arises from a change in Appium’s default server path between Appium versions.
In Appium 1.22.3, the path for the status endpoint has changed from /wd/status to just /`.
Here’s how to fix it:
Update the URL construction:
Instead of getServiceUrl(), use new URL(getServiceUrl(), “/wd/hub”). This adds the necessary path segment.
Explanation:
getServiceUrl() retrieves the base URL from Appium.
Appending /wd/hub specifies the correct endpoint for the status check in Appium 1.22.3.
Muhammad Mushtaq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.