In my case it works only if i mention
...........
.withAppiumJS(
new File(
"/usr/local/lib/node_modules/appium/bin/main.js"))
................
In my case it works only if i mention
...........
.withAppiumJS(
new File(
"/usr/local/lib/node_modules/appium/bin/main.js"))
................
Got the same issue after I upgrade the node and Appium to 1.6, any solution of it?
Try to use main.js instead of appium.js like below
service = new AppiumServiceBuilder()
.usingDriverExecutable(new File("/Users/ssimakurthy/local/bin/node"))
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"));
Please clarify if you’re trying to register android node with Selenium HUB with this code ?
are you able to get this issue resolved ?
Thanks in advance.
Just to update on this thread for benefit of others, with below code I could get appiun node registered with Selenium HUB
String nodeConfigFilePath = “/Users/Mobile-Automation/Android-Automation/serenityAppiumFlipkart/EMULATOR_Nexus_4_1.json”;
AppiumDriverLocalService driverLocalService = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
.usingDriverExecutable(new File("/usr/local/bin/node"))
//.withIPAddress("127.0.0.1")
.usingPort(4445)
//.withArgument(GeneralServerFlag.UIID, "123456")
//.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,
// "" + 2252)
//.withArgument(GeneralServerFlag.CHROME_DRIVER_PORT,
// "" + client.getChromeDriverport())
//.withArgument(GeneralServerFlag.NO_RESET)
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, "debug")
.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));
//Logger.info("Server url: " + driverLocalService.getUrl());
driverLocalService.start();
Before you run this program, make sure to try it out from command line with below command
appium --nodeconfig EMULATOR_Nexus_4_1.json --port 4445
In case you do something wrong as appium --nodeconfig EMULATOR_Nexus_4_1.json --bp 2252, you will get nice output about flags usage
Couple of open queries still as below
it didn’t work with usingAnyFreePort(), I had to explicitly mention port number.
I could register android emulator node, even when it was not in open state, not sure if this is valid ?
Regards,
Vikram
Kindly ignore above answer
Below is the working solution, will share completed project in few weeks
{“capabilities”:[{“browserName”:“Android”,“version”:“4.4.2”,“maxInstances”:1,“platform”:“ANDROID”,“deviceName”:“emulator-5556”}],“configuration”:{“nodeTimeout”:120,“port”:4723,“hubPort”:4444,“proxy”:“org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,“hubHost”:“127.0.0.1”, “nodePolling”:2000, “registerCycle”:10000,“register”:true,“cleanUpCycle”:2000,“timeout”:30000,“maxSession”:1}}
nodeConfigFilePath = "/Users/vikram-anna/.../EMULATOR_Nexus_4_2.json";
driverLocalService = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
.usingDriverExecutable(new File("/usr/local/bin/node"))
.usingPort(4823)
.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,"4824")
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, "debug")
.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));
driverLocalService.start();
Yes, using main.js solve the problem, thanks!
Thanks you guys. The problem has been solved.
Hi @suroit
How did you resolved it. Even me too facing same issue. I am using appium-desktop 1.1.1 and I installed Node.js manually. Below is my code and error. Can you please help?
appiumService = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(“C:/Program Files/nodejs/node”))
.withAppiumJS(new File(“C:/Users/ss.k/AppData/Local/Programs/appium-desktop/resources/app/main.js”))
.withIPAddress(“127.0.0.1”)
.usingPort(4723));
appiumService.start();
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: [C:\Users\ss.k\AppData\Local\Programs\appium-desktop\resources\app\main.js, --port, 4723, --address, 127.0.0.1]
Process output: Error: Cannot find module ‘electron’
I suggest you try the latest version of appium instead of appium-desktop.
Hi guys,
I meet one problem when I try using AppiumDriverLocalSerivce .start() to launch app server, code like below.
public class StartAppium {
private IOSDriver<MobileElement> iosDriver;
private AppiumDriverLocalService service;
@BeforeClass
public void setUp() throws Exception {
service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder().usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
.withIPAddress("127.0.0.1").usingPort(4723));
service.start();
}
@Test
public void getAppiumStatus() {
}
@AfterClass
public void tearDown() {
// iosDriver.quit();
// service.stop();
}
}
however, I got same errors like below, Appium I was using latest one v1.6.5, but strangely it works fine when I use terminal command “node /usr/local/lib/node_modules/appium/build/lib/main.js”
Exception in thread “main” io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/Cellar/node/8.1.4/bin/node Arguments: [/usr/local/lib/node_modules/appium/build/lib/main.js, --port, 57565, --address, 127.0.0.1, --log-level, info, --bootstrap-port, 57567, --suppress-adb-kill-server, --selendroid-port, 57568]
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:149)
at appium.Manager.DeviceConfigurationImpl.main(DeviceConfigurationImpl.java:45)
Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
at org.openqa.selenium.net.UrlChecker.(UrlChecker.java:67)
at io.appium.java_client.service.local.AppiumDriverLocalService.ping(AppiumDriverLocalService.java:113)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:136)
… 1 more
@Sun_Yujiang
I am having the same problem of
Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
when using AppiumDriverLocalSerivce .start() to start appium server.
Did you get a solution?
public static void startServer() throws Exception {
try {
logIOSDriverAPI.info("Starting Appium on terminal from AppiumDriverLocalService");
Map<String, String> env = new HashMap<String, String>(System.getenv());
env.put("PATH", "/usr/local/bin:" + env.get("PATH"));
AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withIPAddress(appiumInit.SERVERIP)
.usingPort(appiumInit.APPIUMPORT)
.withEnvironment(env)
.withArgument(GeneralServerFlag.LOG_NO_COLORS)
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"));
driverLocalService = AppiumDriverLocalService.buildService(builder);
driverLocalService.start();
} catch (Exception e) {
throw new Exception("Exception occoured while starting the appium server");
}
try {
Thread.sleep(10000);
} catch (Exception e) {
e.printStackTrace();
}
}
Hi,
I am facing same issue. i used above code, but no use.
Environment :
Apium version : 17.1
Node : 8.7.0
xcode :9.0
java clinet : 5.0.4
Using following code to start appium :
Map<String, String> env = new HashMap<>(System.getenv());
env.put(“PATH”, “/usr/local/bin:” + env.get(“PATH”));
AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withArgument(IOSServerFlag.WEBKIT_DEBUG_PROXY_PORT, webkit)
.withIPAddress(“127.0.0.1”)
.usingPort(port).withEnvironment(env)
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"));
AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder);
service.start();**
Can anyone suggest me how to solve this issue.
public static void startServer() throws Exception {
try {
logIOSDriverAPI.info("Starting Appium on terminal from AppiumDriverLocalService");
Map<String, String> env = new HashMap<String, String>(System.getenv());
env.put("PATH", "/usr/local/bin:" + env.get("PATH"));
AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withIPAddress(appiumInit.SERVERIP)
.usingPort(appiumInit.APPIUMPORT)
.withEnvironment(env)
.withArgument(GeneralServerFlag.LOG_NO_COLORS)
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"));
driverLocalService = AppiumDriverLocalService.buildService(builder);
driverLocalService.start();
} catch (Exception e) {
throw new Exception("Exception occoured while starting the appium server");
}
try {
Thread.sleep(10000);
} catch (Exception e) {
e.printStackTrace();
}
}
i am using the same code and its working
this worked for me even in IntelliJ IDEA community edition
i just created a Variable and gave path till nodejs directory(NODE HOME)
Hi Vikram,
Will you please share code for programmatic Appium Grid?
I am getting below error, I am using Appium Desktop and all configurations are completed.
Step failed
io.appium.java_client.service.local.InvalidServerInstanceException: The main Appium script does not exist at ‘C:\Users\lenovo\AppData\Roaming\npm\node_modules\appium\build\lib\main.js’
at io.appium.java_client.service.local.AppiumServiceBuilder.findMainScript(AppiumServiceBuilder.java:161)
As soon as Appium is launched though code, the Appium driver fails consistently.
Below is the code for Appium launch:
String appiumPath = Joiner.on(File. separator ).join("/", “Applications”, “Appium.app”, “Contents”,“Resources”,“app”,“node_modules”,“appium”,“build”,“lib”,“main.js”);
String nodePath = Joiner.on(File. separator ).join("/", “usr”, “local”, “bin”,“node”);
if(!checkIfServerisRunning(4723)) {
service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(nodePath))
.withAppiumJS(new File(appiumPath))
.withIPAddress(“127.0.0.1”)
.usingPort(4723)
.withLogFile(new File("** txt"))
service.start();
}
This returns a 200 response.
However once the capabilities are loaded and the driver(AppiumDriver) is initialized,
driver = new AppiumDriver<>(new URL(service.getUrl().toString()), capabilities);
or
driver = new AppiumDriver<>(
new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
this always give me an error as below:
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘WASD17791’, ip: ‘2600:8806:105:ad00:0:0:0:1a99%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘11.0.11’
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
at getResponseForW3CError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)
}
Can you please help me with this?