新手区 MAC appium 报错 A new session could not be created. (Original error: Could not initialize ideviceinstaller; make sure it is installed and works on your system)

潇洒ˇ瑶爷 · 2016年07月04日 · 最后由 潇洒ˇ瑶爷 回复于 2016年07月06日 · 1312 次阅读

背景

  1. 因 appium 长实际运行会报错,需要在程序中去启动 appium 服务
  2. 报的错误是: org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not initialize ideviceinstaller; make sure it is installed and works on your system)
  3. 在 GUI 和终端启动服务都可以正常运行!
  4. 已经试过重装 ideviceinstaller(brew install -HEAD ideviceinstaller)了,还是有问题

此问题已经困扰好久了,希望哪个高人帮忙解答一下,以下是代码:


程序启动 appium 代码 String processName =
"/Applications/Appium.app/Contents/Resources/node/bin/node "
+ "/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/main.js"
+ " --address \"127.0.0.1\" --command-timeout \"7200\" --debug-log-spacing"
+ " --platform-version \"9.1\" --platform-name \"iOS\""
+ " --app \"com.letv.store.iphone.client\""
+ " --udid \"9932377fd430f2e2b0e0bcc1da58179d4ff1e4d7\" --device-name \"iPhone 6\"";
String[] CMDS = new String[3];

CMDS[0] = "/bin/bash";

CMDS[1] = "-c";
CMDS[2] = processName;
Runtime rt = Runtime.getRuntime();
try {

rt.exec(CMDS);
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}catch (ExecuteException e) { // TODO Auto-generated catch block e.printStackTrace(); }

共收到 7 条回复 时间 点赞
Monkey 内容不符合版规屏蔽此话题 07月04日 15:11

请使用 markdown 编辑帖子

#2 楼 @monkey 已经修改,请 monkey 帮忙放开

#3 楼 @wshdong 代码段不应该使用引用标签的。参考一下 markdown 的代码标签。😄

//程序启动appium代码
 String processName =
"/Applications/Appium.app/Contents/Resources/node/bin/node "
+ "/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/main.js"
+ " --address \"127.0.0.1\" --command-timeout \"7200\" --debug-log-spacing"
+ " --platform-version \"9.1\" --platform-name \"iOS\""
+ " --app \"com.letv.store.iphone.client\""
+ " --udid \"9932377fd430f2e2b0e0bcc1da58179d4ff1e4d7\" --device-name \"iPhone 6\"";
String[] CMDS = new String[3]; CMDS[0] = "/bin/bash";

CMDS[1] = "-c"; 
CMDS[2] = processName; 
Runtime rt = Runtime.getRuntime();
try { rt.exec(CMDS);
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}catch (ExecuteException e) { // TODO Auto-generated catch block e.printStackTrace(); }

#4 楼 @xiaozi0lei 好的,下次注意,请帮忙看看问题啊 😂

#5 楼 @wshdong 没遇到你这个问题,以下是我个人思路,你可以尝试一下:
先执行 rt.exec(‘which ideviceinstaller’); 查看一下返回结果能不能拿到 ideviceinstaller。根据报错信息来看,是你 exec 出来的进程获取不到 ideviceinstaller

是不是没有用 driver.exit() 之类的?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册