appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.21k stars 755 forks source link

Cannot start AppiumDriverLocalService in Jenkin #1221

Open HoLeAnh opened 5 years ago

HoLeAnh commented 5 years ago

Description

I can start AppiumDriverLocalService in local but when run on Jenkin, i receive a error : io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: The invalid appium node C:\windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\appium\build\lib\main.js has been defined Caused by: java.io.IOException: The node C:\windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\appium\build\lib\main.jsdoesn't exist

Environment

Appium : 1.8.1 Java client : 5.0.4

Details

Please provide more details, if necessary.

Code To Reproduce Issue [ Good To Have ]

private static final String NODE_JS_PATH = "C:/Program Files/nodejs/node.exe"; private static final String APPIUM_JS_PATH = System.getenv("AppData") + "/npm/node_modules/appium/build/lib/main.js";

AppiumServiceBuilder builder = new AppiumServiceBuilder();
    builder.usingDriverExecutable(new File(NODE_JS_PATH));
    builder.withAppiumJS(new File(APPIUM_JS_PATH));
    builder.usingAnyFreePort();

    AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder);
    service.start();
    service.getUrl();

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(MobileCapabilityType.PLATFORM, platformName);
    caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, platformVersion);
    caps.setCapability(MobileCapabilityType.DEVICE_NAME, usingDeviceId);
    caps.setCapability(MobileCapabilityType.UDID, usingDeviceId);
    caps.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, System.getProperty("user.dir") + "/src/test/java/resources/chromedriver.exe");
    caps.setCapability("unicodeKeyboard", "true");
    caps.setCapability("appPackage", appPackage);
    caps.setCapability("appActivity", appActivity);
    caps.setCapability(AndroidMobileCapabilityType.NATIVE_WEB_SCREENSHOT, true);
    caps.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);

    driver = new AndroidDriver(service, caps);
    driver.manage().timeouts().implicitlyWait(timeDefault, TimeUnit.SECONDS);

Link to Appium logs

Started by timer Running as SYSTEM Building in workspace D:\Workspace\maven_appium [maven_appium] $ cmd /c call C:\windows\TEMP\jenkins1643235431572429234.bat

D:\Workspace\maven_appium>mvn clean test -DsuiteXmlFiles=runSuites/AllRun.xml [INFO] Scanning for projects... [INFO] [INFO] ---------------------< Maven_Appium:Maven_Appium >---------------------- [INFO] Building Maven_Appium 0.0.1-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Maven_Appium --- [INFO] Deleting D:\Workspace\maven_appium\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Maven_Appium --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\Workspace\maven_appium\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ Maven_Appium --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 63 source files to D:\Workspace\maven_appium\target\classes [INFO] /D:/Workspace/maven_appium/src/main/java/actions/APIClass/SellerWeb_Changestock.java: D:\Workspace\maven_appium\src\main\java\actions\APIClass\SellerWeb_Changestock.java uses or overrides a deprecated API. [INFO] /D:/Workspace/maven_appium/src/main/java/actions/APIClass/SellerWeb_Changestock.java: Recompile with -Xlint:deprecation for details. [INFO] /D:/Workspace/maven_appium/src/main/java/actions/ScreenRecord.java: Some input files use unchecked or unsafe operations. [INFO] /D:/Workspace/maven_appium/src/main/java/actions/ScreenRecord.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Maven_Appium --- [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\Workspace\maven_appium\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ Maven_Appium --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 20 source files to D:\Workspace\maven_appium\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ Maven_Appium --- [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [WARNING] Corrupted stdin stream in forked JVM 1. See the dump file D:\Workspace\maven_appium\target\surefire-reports\2019-08-30T03-08-35_575-jvmRun1.dumpstream [INFO] Running TestSuite [TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >" at the top of your file, otherwise TestNG may fail or not work as expected. [TestNG] [WARN] AnnotationTransformer already set ... ... TestNG 6.10 by Cédric Beust (cedric@beust.com) ...

Success to connect database before deviceMapping : {192.168.106.101:5555=true}-13 after deviceMapping : {192.168.106.101:5555=false}-13 [ERROR] Tests run: 313, Failures: 1, Errors: 0, Skipped: 312, Time elapsed: 3.096 s <<< FAILURE! - in TestSuite [ERROR] BeforeClass(chat.Chat) Time elapsed: 2.264 s <<< FAILURE! io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: The invalid appium node C:\windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\appium\build\lib\main.js has been defined Caused by: java.io.IOException: The node C:\windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\appium\build\lib\main.jsdoesn't exist

[INFO] [INFO] Results: [INFO] [ERROR] Failures: [ERROR] Chat>Testbase.BeforeClass:78 » InvalidServerInstance Invalid server instance e... [INFO] [ERROR] Tests run: 155, Failures: 1, Errors: 0, Skipped: 154 [INFO] [ERROR] There are test failures.

Please refer to D:\Workspace\maven_appium\target\surefire-reports for the individual test results. Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 32.731 s [INFO] Finished at: 2019-08-30T03:08:40+07:00 [INFO] ------------------------------------------------------------------------ TestNG Reports Processing: START Looking for TestNG results report in workspace using pattern: **/testng-results.xml Saving reports... Processing 'C:\Program Files (x86)\Jenkins\jobs\Seller _Appium\builds\278\testng\testng-results.xml' TestNG Reports Processing: FINISH Finished: SUCCESS

saikrishna321 commented 5 years ago

io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: The invalid appium node

You need to set the node in PATH or you can point the 'AppiumDriverLocalService' to appium main.js

HoLeAnh commented 5 years ago

io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: The invalid appium node

You need to set the node in PATH or you can point the 'AppiumDriverLocalService' to appium main.js

I have added main.js path on my code but Jenkin not understand it, you can guide me or give me some code reference.

private static final String APPIUM_JS_PATH = System.getenv("AppData") + "/npm/node_modules/appium/build/lib/main.js"; builder.withAppiumJS(new File(APPIUM_JS_PATH));

ashokkumarg commented 3 years ago

@HoLeAnh Did you find the solution?