我使用以下代码以编程方式运行Appium服务器:
public class AppiumTests {
private AppiumDriverLocalService service;
private AppiumServiceBuilder builder;
private DesiredCapabilities cap;
public static AppiumDriver<WebElement> driver;
public void startServer() {
builder = new AppiumServiceBuilder();
builder.withIPAddress("127.0.0.1");
builder.usingPort(4728);
service = AppiumDriverLocalService.buildService(builder);
service.start();
}
public void stopServer() {
service.stop();
}
public void mobileTest() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "Nexus 5");
capabilities.setCapability("platformVersion", "7.1.1");
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("deviceOrientation", "portrait");
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4728/wd/hub"), capabilities);
// My test cases are here
}
public static void main(String[] args) throws MalformedURLException {
AppiumServerJava appiumServer = new AppiumServerJava();
appiumServer.startServer();
appiumServer.mobileTest();
appiumServer.stopServer();
}
}
当我运行它时,Appium服务器按预期启动,但我收到如下信息警告消息:
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@3ac42916
完整输出:
Feb 28, 2018 11:10:27 PM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@58d25a40
Feb 28, 2018 11:10:28 PM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@3ac42916
[Appium] Welcome to Appium v1.7.2
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] port: 4728
[Appium] Appium REST http interface listener started on 127.0.0.1:4728
[HTTP] --> GET /wd/hub/status {}
[debug] [MJSONWP] Calling AppiumDriver.getStatus() with args: []
[debug] [MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.7.2","revision":null}}
[HTTP] <-- GET /wd/hub/status 200 76 ms - 72
Feb 28, 2018 11:10:32 PM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@63d4e2ba
出现这种情况的原因是什么?当然不确定为什么在Appium服务器启动之前它会被显示两次。