Hi,
Currently when I run Appium using Jenkins , I see the following message:io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: There is no installed nodes! Please install node via NPM (https://www.npmjs.com/package/appium#using-node-js) or download and install Appium app (http://appium.io/downloads.html)
at Test_Cases.Android.setUp(Android.java:37)
Caused by: java.io.IOException:
C:\windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules
at Test_Cases.Android.setUp(Android.java:37)
I would like to understand how to explain Jenkins / Help Jenkins to run/ start my Appium Server
My Current Config:
Jenkins: 2.90
Appium Version: 1.7.1
Code to Start/ Stop the Appium Server:
public class AppiumServerJava {
private AppiumDriverLocalService service;
private AppiumServiceBuilder builder;
private DesiredCapabilities cap;
public void startServer() {
//Set Capabilities
cap = new DesiredCapabilities();
cap.setCapability("noReset", "false");
//Build the Appium service
builder = new AppiumServiceBuilder();
builder.withIPAddress("127.0.0.1");
builder.usingPort(4723);
builder.withCapabilities(cap);
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
builder.withArgument(GeneralServerFlag.LOG_LEVEL,"error");
//Start the server with the builder
service = AppiumDriverLocalService.buildService(builder);
service.start();
}
public void stopServer() {
service.stop();
}
public boolean checkIfServerIsRunnning(int port) {
boolean isServerRunning = false;
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket(port);
serverSocket.close();
} catch (IOException e) {
//If control comes here, then it means that the port is in use
isServerRunning = true;
} finally {
serverSocket = null;
}
return isServerRunning;
}
public static void main(String[] args) {
AppiumServerJava appiumServer = new AppiumServerJava();
int port = 4723;
if(!appiumServer.checkIfServerIsRunnning(port)) {
appiumServer.startServer();
System.out.println("Server Started");
appiumServer.stopServer();
System.out.println("Server Stopped");
} else {
System.out.println("Appium Server already running on Port - " + port);
}
}
}
I have the Appium installed as a node and works fine:
C:\Demo\Git_Repo\Netflix Demo>appium --version
1.7.1
Also, the Maven logs for success:
[INFO] Scanning for projects…
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Youtube_Demo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] — maven-resources-plugin:2.6:resources (default-resources) @ Youtube_Demo —
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Demo\Git_Repo\Netflix Demo\src\main\resources
[INFO]
[INFO] — maven-compiler-plugin:3.6.1:compile (default-compile) @ Youtube_Demo —
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ Youtube_Demo —
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Demo\Git_Repo\Netflix Demo\src\test\resources
[INFO]
[INFO] — maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ Youtube_Demo —
[INFO] No sources to compile
[INFO]
[INFO] — maven-surefire-plugin:2.20.1:test (default-test) @ Youtube_Demo —
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Server Started
Extent Flushed
Mobile Driver Closed
Stopping Appium Driver
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 39.574 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 42.657 s
[INFO] Finished at: 2017-11-17T10:38:30-05:00
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------