首页 > 解决方案 > android真机无法启动app,appium服务器自动关闭

问题描述

**Environment** 
- java client build version : 6.1.0 
- Appium server version : 1.7.1 
- Desktop OS/version used to run Appium if necessary: Windows 7 
- Node.js version : 6.4.1 
- Mobile platform/version under test: Android/ 8.1.0 
- Real device or emulator/simulator: Real device 
- Selenium Version: 3.12.0
- TestNg Version : 6.14.3 

在设置了以下所需功能后仍然无法启动应用程序,控制台上仍然出现错误“线程“主”org.openqa.selenium.WebDriverException 中的异常:无法创建新会话,因为“createSession”需要 HttpClient、InputStream并且长期未找到或无法访问“但是由于出现此错误而无法获取appium服务器日志appium服务器自动关闭:我在执行期间为appium服务器日志捕获了视频请查找截屏视频:  https://www .screencast.com/t/4f8j8cEveZ

 Code To Reproduce Issue [ Good To Have ] 
public class launchApp {
AndroidDriver<WebElement> driver;

@BeforeClass
public void beforeClass() throws MalformedURLException, InterruptedException {
    DesiredCapabilities capab = new DesiredCapabilities();

    capab.setCapability("deviceName", "Redmi Note 5");
    capab.setCapability("udid", "35924c6f0804");
    capab.setCapability("platformName", "Android");
    capab.setCapability("platformVersion", "8.1.0");
    capab.setCapability("appPackage", "com.miui.calculator");
    capab.setCapability("appActivity", "com.miui.calculator.cal.CalculatorActivity");
    driver = new AndroidDriver<WebElement>(new URL("http://0.0.0.0:4723/wd/hub"), capab);
   
     Thread.sleep(5000);
}

@Test
public void m1() throws InterruptedException {
    System.out.println("kfd");
    Thread.sleep(2000);
   
}
}




Ecxeption stacktraces 
Console Exception:
org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'OFFICE-PC', ip: '---.---,---', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_152-release'
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:195)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:209)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
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:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:93)
at com.example.office.appium_project.launchApp.beforeClass(launchApp.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648) 

标签: javaseleniumselenium-webdriverappiumappium-android

解决方案


推荐阅读