Appium v1.6.13
Windows 7
I read through almost all the discussions related to this header, however, I could't find a solution to the issue I am facing.
I am trying to Launch appium from within my Project using Java. Below is code I am using to launch the appium server
static PropertyFileReader reader = new PropertyFileReader();
static String Appium_Node_Path = reader.nodejsPath();
static String Appium_JS_Path = reader.appiumPath();
static AppiumDriverLocalService service;
static String service_url;
static File file = new File(System.getProperty("user.dir") + "/appium.log");
public static void main(String[] args) throws Exception {
service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(Appium_Node_Path))
.withAppiumJS(new File(Appium_JS_Path))
.withLogFile(file));
service.start();
service_url = service.getUrl().toString();
System.out.println(service_url);
}
}
Now, I first tried with the path of the appium.js file and faced error in launching appium. Based on the suggestions in the blogs, I replaced the path to the main.js file. Still I get the below exception and am unable to launch the server
Exception in thread "main" io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [D:\Users\ASAJATSH\AppData\Roaming\npm\node_modules\appium\lib\main.js, --port, 4723, --address, 0.0.0.0, --log, D:\Users\ASAJATSH\workspace\Go\appium.log]
Process output: D:\Users\ASAJATSH\AppData\Roaming\npm\node_modules\appium\lib\main.js:4
import { init as logsinkInit } from './logsink';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:155)
at com.Astro.common.Base.AstroBaseTest.main(AstroBaseTest.java:37)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://0.0.0.0:4723/wd/hub/status] to be available after 120007 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at io.appium.java_client.service.local.AppiumDriverLocalService.ping(AppiumDriverLocalService.java:115)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:142)
... 1 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
... 3 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 4 more
Please help me on this as I am not able to make the reason for this exception. Thanks in Advance.