- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在为我的机器上运行的 Appium 服务器运行代码时总是出错。谁能帮我解决这个问题。我关注了一些主题,但没有一个不能解决我的问题。
如果我手动运行“appium.exe”并且运行代码工作正常,但是当我开始从代码运行 appium 并且交互时出现问题。
配置:Windows 7 64 位、Appium 1.2.4.1、Selenium 2.45、Appium Java 客户端 - 2.2、java 1.6
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();
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' System info: host: '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 info: 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.java:109) at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:40) at com.helloappium.HelloAppium.main(HelloAppium.java:48) Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:4723 [/127.0.0.1] failed: Connection refused: connect at 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.execute(ApacheHttpClient.java:72) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:133) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572) ... 7 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at 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 more [36minfo[39m: Welcome to Appium v1.2.4 (REV 71584425ecf777349e3215f0f18e71e7782acfb6) [36minfo[39m: Appium REST http interface listener started on 127.0.0.1:4723 [36minfo[39m: [debug] Non-default server args: {"address":"127.0.0.1","noReset":true,"log":"F:\Softwares\Selenium\Appium\appiumServerLogs.txt","localTimezone":true,"selendroidPort":8082} [36minfo[39m: Console LogLevel: debug [36minfo[39m: File LogLevel: debug
最佳答案
我设法重现了这个问题。出现这个问题是因为appium需要比较长的时间来启动。如果将您构建的命令行复制到 cmd 提示符并启动它,您可以看到它。 appium 准备就绪大约需要 30 秒。所以肮脏的解决方案只是在移动脚本中的 aServer.startServer();
之后添加 Thread.sleep(30000);
。更好的解决方案是等到 appium 准备好。为此,我认为最好的方法是读取输出流并验证它是否包含预期的响应。
这段简单的代码展示了这种方法(没有响应验证)
InputStream is = new InputStream() {
@Override
public int read() throws IOException {
return 0;
}
};
executor.getStreamHandler().setProcessOutputStream(is);
try {
executor.execute(command, resultHandler);
for (int i=1; i<10; i++) {
int nRead = is.read();
if(nRead!=0)
break;
Thread.sleep(5000);
}
}catch (IOException e) {
e.printStackTrace();
}catch (InterruptedException e) {
e.printStackTrace();
}
}
关于android - 异常线程 "main"org.openqa.selenium.remote.UnreachableBrowserException : Could not start a new session, 使用 appium 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30302110/
我刚刚注意到 align-self 属性的一些值,这是我以前从未见过的。什么是start、end、self-start、self-end,它们与有什么区别>flex-start 和 flex-end?
我见过程序员使用公式 mid = start + (end - start) / 2 而不是使用更简单的公式 mid = (start + end) / 2 用于查找数组或列表中的中间元素。 为什么他
我们已经设置了一个小型 AZURE VM(由 Microsoft 提供的普通 Windows 2012 R2 镜像),其中包含一个轻量级 DEMO 应用程序,该应用程序可以与 SQLExpress 和
我在笔记本电脑上安装了Xampp 3.2.1版,之前MySQL在它上面运行得很好,但突然MySQL停止运行,而阿帕奇和其他公司都在运行。当我点击开始MySQL时,它显示这个错误我使用Windows 1
我希望我能解释清楚。 我有自动生成的代码,我希望用 CSS 覆盖它。 这是我希望覆盖的代码示例: #u1150:hover #u1153-4 p {color: red} 重要提示:此代码中的“u”将
在我的 package.json 中,我有以下脚本 block : "scripts": { "start": "react-scripts start",
https://github.com/lodash/lodash/blob/3.7.0/lodash.src.js#L2781 此代码段 start = start == null 中的 +start
上下文 我一直在阅读有关如何将 TUMBLINGWINDOW 函数与 TIMSTAMP BY 子句一起使用的文档,但似乎找不到有关如何计算包含 TUMBLING WINDOW 和 TIMESTAMP
我正在使用 Grunt 运行 Protractor 端到端测试用例。我有以下三个任务(我使用的是 windows 7 机器) webdriver-stop webdriver-start Protra
我正在创建一个简单的Java程序,它具有在窗口生成器的帮助下构建的GUI。 GUI只包含一个按钮。 单击按钮后,启动一个线程,该线程将无限次打印到随机数,直到再次单击同一按钮将其停止为止。 这是我的代
我一直在摆弄创建一个运行渲染的线程,并且我遇到了这种实现它的方法: Class Main implements Runnable { private Thread thread; private bo
我如何在 StartButton 类中编写一个 touchesBegun 命令,它在场景中调用 start() 任何实例本身? 我知道......可能是 OOP 101。但今天我远远超出了我的范围。
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 8年前关闭。 Improve this questi
我的目标是运行多个进程并保存它们的 ProcessName和 Id供以后使用。这是我的代码 [System.Collections.ArrayList]$startedProcesses = @()
我在 8086 汇编方面没有太多经验,我想知道如果您不写起始标签 (start:) 和该标签的结尾,程序会发生什么 (end start)(围绕执行代码的标签)? 所以我的问题是这个标签是否是执行所必
我在 8086 汇编方面没有太多经验,我想知道如果您不写起始标签 (start:) 和该标签的结尾,程序会发生什么 (end start)(围绕执行代码的标签)? 所以我的问题是这个标签是否是执行所必
我想在另一个脚本的 Start() 之前从一个脚本运行 Start()。是否可以?您可以选择脚本的执行顺序吗? 最佳答案 我不太确定 Start() 但您可以配置 Awake 的脚本执行顺序,OnEn
我有一个来自 Unity 文档页面的示例程序,其中包含 IEnumerator Start() ,如下所示,但我想知道如何才能拥有正常的 void Start() > 在同一个脚本中? 我也尝试添加v
正如标题所说,“从机启动”和“从机启动”有什么区别?当我接受DBA面试时,他问了这个问题,我搜索了google但没有找到答案,有人知道吗? 最佳答案 没有区别.. Slave start; 已弃用,现
我有几十个未记录的表,文档说未记录的表在崩溃或不正常关机后会自动截断。 基于此,我需要在数据库启动后检查一些表,看它们是否为“空”并采取一些措施。 简而言之,我需要在数据库启动后立即执行一个过程。 最
我是一名优秀的程序员,十分优秀!