org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。在模拟器中初始化android驱动程序时

Posted

技术标签:

【中文标题】org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。在模拟器中初始化android驱动程序时【英文标题】:org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. while initializing android driver in emulator 【发布时间】:2017-04-02 06:54:43 【问题描述】:

在模拟器设备中初始化 android 驱动程序时产生 sessionNotCreatedException。是 android 自动化的新手。有人请帮忙吗?。

2016 年 11 月 18 日下午 5:35:25 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:尝试双语会话,假设 Postel 定律在远程端成立 2016 年 11 月 18 日下午 5:35:25 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:回退到直接 W3C 远程端连接 2016 年 11 月 18 日下午 5:35:25 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:回退到原始的 OSS JSON Wire 协议。 org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。 构建信息:版本:'未知',修订:'c7b525d',时间:'2016-09-01 14:52:30 -0700' 系统信息:主机:'thangaraj',ip:'127.0.1.1',os.name:'Linux',os.arch:'amd64',os.version:'3.19.0-25-generic',java.version :'1.8.0_101' 驱动信息:driver.version:AndroidDriver 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618) 在 io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40) 在 io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) 在 io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) 在 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142) 在 io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:36) 在 io.appium.java_client.AppiumDriver.(AppiumDriver.java:114) 在 io.appium.java_client.AppiumDriver.(AppiumDriver.java:132) 在 io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:92) 在初始化.Setup.initialize(Setup.java:230) 在 script.ScriptRunner.setup(ScriptRunner.java:67) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100) 在 org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515) 在 org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216) 在 org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143) 在 org.testng.SuiteRunner.privateRun(SuiteRunner.java:307) 在 org.testng.SuiteRunner.run(SuiteRunner.java:270) 在 org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 在 org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 在 org.testng.TestNG.runSuitesSequentially(TestNG.java:1284) 在 org.testng.TestNG.runSuitesLocally(TestNG.java:1209) 在 org.testng.TestNG.runSuites(TestNG.java:1124) 在 org.testng.TestNG.run(TestNG.java:1096) 在 runTestNG.RunTestng.runTestNG(RunTestng.java:19) 在 runner.Runner.main(Runner.java:11) 原因:org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。所需功能 = 功能 [app=/home/ionixx/Android/Sdk/platform-tools/xxxxxxxxxxxxxxx.apk, appPackage=xxxxxxxxxxxxxxxxxx, appActivity=xxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxx, noReset=true, browserName=, maxSession=10, platformName=Android,版本=4.4,设备名称=Nexus1],所需功能=空 构建信息:版本:'未知',修订:'c7b525d',时间:'2016-09-01 14:52:30 -0700' 系统信息:主机:'thangaraj',ip:'127.0.1.1',os.name:'Linux',os.arch:'amd64',os.version:'3.19.0-25-generic',java.version :'1.8.0_101' 驱动程序信息:driver.version:AndroidDriver 在 org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:80) 在 org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) 在 io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:597)

【问题讨论】:

【参考方案1】:

请检查包含 selenium 2.53.1 源代码和 2.53.1 jar 的软件包。并在提取 selenium 2.53.1 后包含 lib 文件夹中存在的所有 jar 文件。 - 使用 testng.xml 文件设置测试用例的流程。

作者:Imran Ansari,我的同事。

【讨论】:

【参考方案2】:

我只是通过更改应用程序路径解决了这个问题

 capabilities.setCapability("app", <<apk file path>>);

【讨论】:

【参考方案3】:

更改正确的 App 路径(apk 路径)后工作。

【讨论】:

以上是关于org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。在模拟器中初始化android驱动程序时的主要内容,如果未能解决你的问题,请参考以下文章