Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Eclipse中从Java代码启动appium服务器_Java_Selenium_Appium - Fatal编程技术网

如何在Eclipse中从Java代码启动appium服务器

如何在Eclipse中从Java代码启动appium服务器,java,selenium,appium,Java,Selenium,Appium,我试图从测试用例代码以编程方式启动appium服务器,但没有任何帮助。控制台始终向我发送“org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败”错误消息。到目前为止,我尝试了什么: CommandLine command = new CommandLine("cmd"); command.addArgument("/c"); command.addArgument("C:/Pr

我试图从测试用例代码以编程方式启动appium服务器,但没有任何帮助。控制台始终向我发送“org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败”错误消息。到目前为止,我尝试了什么:

CommandLine command = new CommandLine("cmd");
command.addArgument("/c");
command.addArgument("C:/Program Files (x86)/Appium/node.exe");
command.addArgument("C:/Program Files (x86)/Appium/node_modules/appium/bin/appium.js");
        command.addArgument("--address");
        command.addArgument("127.0.0.1");
        command.addArgument("--bootstrap-port");
        command.addArgument("5001");
        command.addArgument("--no-reset");
        command.addArgument("--log");
不起作用。下一步:

DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        DefaultExecutor executor = new DefaultExecutor();
        executor.setExitValue(1);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node.exe"), resultHandler);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --selendroid-port 8082 --no-reset --local-timezone"), resultHandler);
ProcessBuilder pb = new ProcessBuilder("C:/Program Files(x86)/Appium/node.exe/");
        ProcessBuilder pb1 = new ProcessBuilder("C:/Program Files(x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 5002 --no-reset --local-timezone");
        pb.start();
        pb1.start();
String path = "cmd /c start C:/Users/jamesrobinson/Desktop/Run automation servers.bat";
        Runtime rn = Runtime.getRuntime();
        Process process = rn.exec(path);
不起作用。下一步:

DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        DefaultExecutor executor = new DefaultExecutor();
        executor.setExitValue(1);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node.exe"), resultHandler);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --selendroid-port 8082 --no-reset --local-timezone"), resultHandler);
ProcessBuilder pb = new ProcessBuilder("C:/Program Files(x86)/Appium/node.exe/");
        ProcessBuilder pb1 = new ProcessBuilder("C:/Program Files(x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 5002 --no-reset --local-timezone");
        pb.start();
        pb1.start();
String path = "cmd /c start C:/Users/jamesrobinson/Desktop/Run automation servers.bat";
        Runtime rn = Runtime.getRuntime();
        Process process = rn.exec(path);
不起作用。下一步:

DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        DefaultExecutor executor = new DefaultExecutor();
        executor.setExitValue(1);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node.exe"), resultHandler);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --selendroid-port 8082 --no-reset --local-timezone"), resultHandler);
ProcessBuilder pb = new ProcessBuilder("C:/Program Files(x86)/Appium/node.exe/");
        ProcessBuilder pb1 = new ProcessBuilder("C:/Program Files(x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 5002 --no-reset --local-timezone");
        pb.start();
        pb1.start();
String path = "cmd /c start C:/Users/jamesrobinson/Desktop/Run automation servers.bat";
        Runtime rn = Runtime.getRuntime();
        Process process = rn.exec(path);

我只能从UI手动启动它。如果您有任何解决方案,我们将不胜感激

在您共享屏幕截图之前,我猜更改为
默认端口可能有助于您成功创建会话:

command.addArgument("--bootstrap-port");
command.addArgument("4723");
一般单行命令如下所示:

String command = "/Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/main.js --command-timeout 120 --session-override" + nativelib + " --platform-name " + mobileOS + " --log-timestamp -a 0.0.0.0 -p "+4723; //+" --chromedriver-port "+chromePort+" -bp "+bootstrapPort;
在哪里

nativelib = " --native-instruments-lib"; //for iOS
nativelib = ""; //for android


先决条件:

DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
        DefaultExecutor executor = new DefaultExecutor();
        executor.setExitValue(1);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node.exe"), resultHandler);
        executor.execute(new CommandLine("C:/Program Files (x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --selendroid-port 8082 --no-reset --local-timezone"), resultHandler);
ProcessBuilder pb = new ProcessBuilder("C:/Program Files(x86)/Appium/node.exe/");
        ProcessBuilder pb1 = new ProcessBuilder("C:/Program Files(x86)/Appium/node_modules/appium/bin/Appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 5002 --no-reset --local-timezone");
        pb.start();
        pb1.start();
String path = "cmd /c start C:/Users/jamesrobinson/Desktop/Run automation servers.bat";
        Runtime rn = Runtime.getRuntime();
        Process process = rn.exec(path);
  • 确保系统中安装了nodejs
  • 确保系统中安装了appium
  • --在下面给定的脚本中输入两者的位置


    您能否共享成功运行的
    UI常规设置
    的屏幕截图。我可以在您的尝试中看到很多端口更改。我想我了解问题所在,我可以通过编程方式启动appium服务器,但由于无法访问BrowserException,该代码失败………驱动程序信息:driver.version:AndroidDriver。但奇迹是,如果我从用户界面手动启动appium服务器,则不会出现任何故障。是的,我肯定可以共享屏幕截图。你可以在问题中附加相同的内容:如何创建命令字符串,以及如何在bat文件中写入命令。我理解如何将任何文本文件保存为.bat。也许你是这个意思。另外,您能解释一下如何向发送请求吗。任何类型的响应都将不胜感激。我在回答中添加了代码,可以用来发送GET请求和检查响应。我的意思和你说的一样,将文本保存在一个文件中为.bat。我试图在Selnium网格中注册一个Appium节点,但总是得到一个错误:node.exe node_modules\Appium\bin\Appium.js--nodeconfig“C:\XXX\IXXX\XXX.json”-p 4723-U d66d8f10信息:欢迎使用Appium v1.4.16(版本ae6877eff263066b26328d457bd285c0cc62430d)信息:Appium REST http接口侦听器在0.0.0:4723上启动信息:[调试]非默认服务器参数:{“udid”:“d66d8f10”,“nodeconfig”:“C:\\XXX\\XXX\\XXX\\XXX.json”}信息:控制台日志级别:调试错误:无法加载节点配置文件以向网格注册我已成功启动Selenium网格服务器并访问该服务器。我已将appium节点注册到网格,您是否可以检查您的node.json是否真的存在于给定位置,或者是否为正确的json格式,只需粘贴no将de.json发送到jsonlint.com,看看是否可以,我正在将整个node.json内容粘贴到我的答案中,这可能会对您有所帮助。谢谢。