安裝nodejs起因,本地在運行appium自動化用例時,報如下錯誤: Running com.vimalselvam.stf.AndroidTest Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@4361bd48 四月 26, 2021 2:30:07 下午 com.vimalselvam.DeviceApi connectDevice 嚴重: Device is in use Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 1.854 sec <<< FAILURE! setup(com.vimalselvam.stf.AndroidTest) Time elapsed: 1.72 sec <<< FAILURE! io.appium.java_client.service.local.InvalidNodeJSInstance: Node.js is not installed! at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:20 1) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296) at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:74) at io.appium.java_client.service.local.AppiumDriverLocalService.buildDefaultService(AppiumDriverLocalService.j ava:70) at com.vimalselvam.stf.AndroidTest.createAppiumService(AndroidTest.java:35) at com.vimalselvam.stf.AndroidTest.setup(AndroidTest.java:56) Caused by: java.lang.NullPointerException: Unable to find executable for: node.exe at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:251) at org.openqa.selenium.os.UnixProcess.(UnixProcess.java:62) at org.openqa.selenium.os.CommandLine.(CommandLine.java:38) at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:19 5) ... 38 more Results : Failed tests: setup(com.vimalselvam.stf.AndroidTest): Node.js is not installed! Tests run: 4, Failures: 1, Errors: 0, Skipped: 3 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 16.593 s [INFO] Finished at: 2021-04-26T14:30:08+08:00 錯誤分析: 從部分關(guān)鍵錯誤,,很容易看出nodejs沒有安裝,,所以在啟動appium server時報該錯誤。
官網(wǎng)下載對應(yīng)系統(tǒng)版本即可:http:///download/ 下載msi格式的安裝包,,直接下一步下一步安裝即可,,注意更改安裝路徑(默認C盤); 此種方式安裝好以后,會默認把環(huán)境變量配好,,可以在cmd命令窗口直接使用,。 注意:此處你安裝的版本應(yīng)該是與后面要下載的appium的版本是有關(guān)聯(lián)的,有些版本它不能相互兼容,,導致下載不下來(本例中卸載重裝了3次,,從15.0.0->13.13.0->12.9.0) 所以,你可以大致看一下你要用的appium版本它的發(fā)布時間,,然后根據(jù)這個時間去找對應(yīng)的nodejs當時大致的版本,,然后下載下來,這樣成功率高一些,。 2.cmd驗證是否安裝成功C:\Users\Administrator>node -v v12.9.0 C:\Users\Administrator>npm -v 6.10.2 3.設(shè)置taobao倉庫#設(shè)置倉庫為 taobao的,,這樣安裝軟件的時候快一些 C:\Users\Administrator>npm config set registry https://registry.npm. 4.安裝appium如下圖,沒有安裝成功
|
|