Ошибка при выполнении кода для сервера Appium, который работает на моей машине. Может ли кто-нибудь помочь мне в этом. Я следил за потоками, но никто из них не смог решить мою проблему.Исключение из потока «main» org.openqa.selenium.remote.UnreachableBrowserException: не удалось запустить новый сеанс, при использовании appium
Если я запускаю вручную «appium.exe» & код запуска работает нормально, но когда я запускаю appium из кода &, взаимодействие вызывает проблему.
Конфигурации: Windows 7 64 бит, Appium 1.2.4.1, Селен 2,45, Appium Java клиент - 2.2, Java 1.6
Ниже приведен код для запуска сервер Appium программно
public class AppiumServerUtils {
public void startServer(){
CommandLine command = new CommandLine("cmd");
command.addArgument("/c");
command.addArgument("F:\\Softwares\\Selenium\\Appium\\AppiumForWindows-1.2.4.1\\Appium\\node.exe");
command.addArgument("F:\\Softwares\\Selenium\\Appium\\AppiumForWindows-1.2.4.1\\Appium\\node_modules\\appium\\bin\\appium.js");
command.addArgument("--address");
command.addArgument("127.0.0.1",false);
command.addArgument("--port",false);
command.addArgument("4723",false);
command.addArgument("--bootstrap-port",false);
command.addArgument("4724",false);
command.addArgument("--selendroid-port",false);
command.addArgument("8082",false);
command.addArgument("--no-reset",false);
command.addArgument("--local-timezone");
command.addArgument("--log");
command.addArgument("F:\\Softwares\\Selenium\\Appium\\appiumServerLogs.txt");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {
executor.execute(command, resultHandler);
} catch (IOException e) {
e.printStackTrace();
}
}
public void stopServer(){
CommandLine command = new CommandLine("cmd");
command.addArgument("/c");
command.addArgument("taskkill");
command.addArgument("/F");
command.addArgument("/IM");
command.addArgument("node.exe");
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {
executor.execute(command, resultHandler);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Мой сценарий для мобильных устройств,
static AndroidDriver driver;
AppiumServerUtils aServer = new AppiumServerUtils();
aServer.startServer();
DesiredCapabilities mDesiredCapabilities = new DesiredCapabilities();
mDesiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
mDesiredCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus S");
mDesiredCapabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.android.vod");
mDesiredCapabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, "com.android.vod.launcher.Main");
mDesiredCapabilities.setCapability(MobileCapabilityType.APP_WAIT_ACTIVITY, "com.android.vod.tools.remotecontrol.dialogs.Authentication");
mDesiredCapabilities.setCapability(MobileCapabilityType.VERSION, "4.3");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), mDesiredCapabilities);
androidDriver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
androidDriver.hideKeyboard();
driver.close();
Получение followin g Исключения,
Исключение в теме "main" org.openqa.selenium.remote.UnreachableBrowserException: Не удалось запустить новый сеанс. Возможными причинами являются неверный адрес удаленного сервера или неудачный запуск браузера. Информация о сборке: версия: '2.45.0', версия: '5017cb8', время: '2015-02-26 23:59:50' Системная информация: хост: 'Saravanan-PC', ip: '192.168.101.22 ', os.name:' Windows 7 ', os.arch:' x86 ', os.version:' 6.1 ', java.version:' 1.6.0_45 ' Информация о драйвере: driver.version: AndroidDriver at org.openqa .selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:593) at io.appium.java_client.AppiumDriver.execute (AppiumDriver.java:180) at org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java : 240) at org.openqa.selenium.remote.RemoteWebDriver. (RemoteWebDriver.java:126) at org.openqa.selenium.remote.RemoteWebDriver. (RemoteWebDriver.java:153) at io.appium.java_client.AppiumDriver . (AppiumDriver.jav a: 109) at io.appium.java_client.android.AndroidDriver. (AndroidDriver.java:40) at com.helloappium.HelloAppium.main (HelloAppium.java:48) Вызвано: org.apache.http.conn .HttpHostConnectException: Подключиться к 127.0.0.1:4723 [/127.0.0.1] не удалось: соединение отклонено: подключите по адресу org.apache.http.impl.conn.HttpClientConnectionOperator.connect (HttpClientConnectionOperator.java:142) at org.apache. http.impl.conn.PoolingHttpClientConnectionManager.connect (PoolingHttpClientConnectionManager.java:319) at org.apache.http.impl.execchain.MainClientExec.establishRoute (MainClientExec.java:363) at org.apache.http.impl.execchain. MainClientExec.execute (MainClientExec.java:219) at org.apache.http.impl.execchain.ProtocolExec.execute (ProtocolExec. java: 195) at org.apache.http.impl.execchain.RetryExec.execute (RetryExec.java:86) at org.apache.http.impl.execchain.RedirectExec.execute (RedirectExec.java:108) at org.apache.http.impl.client.InternalHttpClient.doExecute (InternalHttpClient.java:184) at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:72) at org.apache.http. impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:57) at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute (ApacheHttpClient.java:126) at org.openqa.selenium.remote.internal.ApacheHttpClient. выполнить (ApacheHttpClient.java: 72) at org.openqa.selenium.remote.HttpCommandExecutor.execute (HttpCommandExecutor.java:133) at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:572) ... еще 7 Вызванный: java.net.ConnectException: Соединение отклонено: подключение на java.net.PlainSocketImpl.socketConnect (Native Method) в java.net.PlainSocketImpl.doConnect (PlainSocketImpl.java:351) в java.net.PlainSocketImpl .connectToAddress (PlainSocketImpl.java:213) на java.net.PlainSocketImpl.connect (PlainSocketImpl.java:200) на java.net.SocksSocketImpl.connect (SocksSocketImpl.java:366) на java.net.Socket.connect (Socket.java:529) at org.apache .http.conn.socket.PlainConnectionSocketFactory.connectSocket (PlainConnectionSocketFactory.java:72) at org.apache.http.impl.conn.HttpClientConnectionOperator.connect (HttpClientConnectionOperator.java:125) ... 20 еще [36minfo [39m : Добро пожаловать в Appium v1.2.4 (REV 71584425ecf777349e3215f0f18e71e7782acfb6) [36minfo [39m: прослушиватель http: Appium REST http начался с 127.0.0.1:4723 [36minfo [39m: [debug] Аргументы сервера по умолчанию: {"address": " 127.0.0.1 "," noReset ": true," log ":" F: \ Software \ Sewenium \ Appium \ appiumServerLogs.txt "," localTimezone ": true," selendroidPort ": 8082} [36minfo [39m: Консоль LogLevel : debug [36minfo [39m: Файл LogLevel: debug
Спасибо. Не могли бы вы сказать мне, где использовать int read = is read(); – saravana
Сразу после команды выполнения вы можете записать цикл, который проверяет статус каждые 5 секунд. Пожалуйста, не забудьте принять ответ, если это поможет, спасибо – Eugene
Конечно. Нужно ли добавлять 5 секунд после выполнения команды? или вы могли бы поделиться некоторым кодом для этого – saravana