当我运行appium测试用例时,我得到了这个错误,下面是我的程序
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class Sample {
@Test
public void m1() throws MalformedURLException, InterruptedException{
// Create object of desired class and specify android platform
DesiredCapabilities capabilities = DesiredCapabilities.android();
// set the capabilities to execute in chrome browser
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, BrowserType.CHROME);
// set capability to execute our test in Android platform
capabilities.setCapability(CapabilityType.PLATFORM, Platform.ANDROID);
// need to define platform name
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
// set device name
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "My Mobile");
// set version
capabilities.setCapability(CapabilityType.VERSION, "6.0");
// create object of url and assign appium server address
URL url = new URL("http://127.0.0.1:4723/wd/hub");
WebDriver driver = new AndroidDriver<>(url, capabilities);
driver.get("http://www.facebook.com");
System.out.println(driver.getTitle());
driver.findElement(By.name("email")).sendKeys("suhailxxxxx@gmail.com");
driver.findElement(By.name("pass")).sendKeys("xxxxxxxxx");
Thread.sleep(10000);
}
}下面是我在日食中遇到的问题
FAILED: m1
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: spawn "D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe" ENOENT) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 11.87 seconds
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'ACC-H-SUHAAHME', ip: '172.18.201.83', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_144'
Driver info: driver.version: AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:362)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:255)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:237)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:138)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:87)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:111)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:72)
at io.app.Sample.m1(Sample.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)这就是我在appium服务器上遇到的问题
信息:调试使用快速重置?真信息:调试准备设备的会话信息:调试,而不是检查应用程序是否存在,因为我们假设它已经在设备信息:检索设备信息:调试试图找到一个连接的android设备信息:调试获取连接设备.信息:调试执行cmd:"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe“设备信息:调试1设备连接信息:已找到的设备PBG6WSCEM7QSTK69信息:将调试设备id设置为PBG6WSCEM7QSTK69信息:调试等待设备就绪并响应shell命令(timeout = 5)信息:调试执行cmd:"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe”-s PBG6WSCEM7QSTK69等-设备信息:调试重试restartAdb信息:调试执行cmd: restartAdb -s PBG6WSCEM7QSTK69杀害服务器信息:调试获取连接的设备.信息:调试执行cmd:"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe“-s PBG6WSCEM7QSTK69设备信息:调试1设备连接信息:调试等待设备就绪并响应shell命令(timeout = 5)信息:调试执行cmd:"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe”-s PBG6WSCEM7QSTK69等待设备信息:调试执行cmd:"D:\ \“softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe“-s PBG6WSCEM7QSTK69 shell”回声‘就绪’“信息:调试启动日志捕获信息:调试清除appium会话错误: Logcat捕获失败:生成"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe”ENOENT错误:未能启动Appium会话,错误是:错误:产生"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe“ENOENT信息:调试错误:在exports._errnoException (util.js:746:11)处生成"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe”ENOENT ( Process.ChildProcess._handle.onexit (child_process.js:1054:32) at child_process.js:1145:20 at child_process.js:1145:20)process._tickDomainCallback (node.js:381:11)信息:调试对客户端的错误响应:{“node.js:381:11”:33,“value”:{“message”:“无法创建新会话。(原始错误:生成\"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe\“ENOENT)、”代码“:”ENOENT“、"errno":"ENOENT”、"syscall":"spawn \"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe\"","path":"\"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe\"",““\"D:\softwares\Appium_New\android-sdk-windows\platform-tools\adb.exe\”origValue“:”产卵“},"sessionId":null} info:<-- POST /wd/集线器/会话10417.138 ms - 510
发布于 2017-10-05 17:34:35
更新你的appium服务器,节点JS和npm,然后尝试它。它为我工作,我在更新到1.7.1版本后使用appium服务器1.4,它工作了。
发布于 2017-09-22 13:08:53
请检查你的APPIUM服务器,它是否已启动。
发布于 2017-10-07 18:56:52
能否关闭当前appium会话,然后再试一次。如果您仍然看到错误,您的appium版本是什么?
https://stackoverflow.com/questions/46361336
复制相似问题