我无法使用APPIUM在设备中启动Android应用程序。请在下面找到我的代码:
public static void main(String[] args) throws MalformedURLException {
File appDir = new File("src");
File app = new File(appDir,"Mast_sab.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME,"071ce659018966d9");
cap.setCapability(MobileCapabilityType.APP_PACKAGE,"com.sabm.mast");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,"1000");
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
AndroidDriver driver = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"),cap);
}
出现以下错误:
error: Unhandled error: Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26) context: [POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.sabm.mast","app":"/Users/sudhir.pandit/Documents/workspace/Learning/src/Mast_sab.apk","platformName":"Android","deviceName":"071ce659018966d9","newCommandTime]
请帮助解决此错误。
2条答案
按热度按时间bogh5gae1#
请将127.0.0.1localhost添加到您的主机(私有/etc/hosts)文件中并运行代码
ia2d9nvy2#
对于Linux用户:如果您在/etc/hosts中添加localhost条目后仍然遇到问题,则可能是nscd守护程序未启动。