简体   繁体   English

InvocationTargetExceptionMessage 是:不可能创建新的 session 因为“createSession”错误

[英]InvocationTargetExceptionMessage is : It is impossible to create a new session because 'createSession' error

I am trying to set up a simple selenium Framework to run off Appium.我正在尝试设置一个简单的 selenium 框架来运行 Appium。 The test should simply open Chrome on an android device.测试应该只是在 android 设备上打开 Chrome。 I have created my Baseclass which us unfortunately returning an error我创建了我的基类,不幸的是我们返回了一个错误

My original thinking was that this issue was related to the URL which is http://0.0.0.0:4723/wd/hub , I changed it but the error was still displayed.我最初的想法是这个问题与 URL 即http://0.0.0.0:4723/wd/hub有关,我更改了它但仍然显示错误。 I have also changed my Java version client but every time I do this another error appears!!我还更改了我的 Java 版本客户端,但每次我这样做时都会出现另一个错误!

My Appium version is the following..我的 Appium 版本如下..

[Appium] Welcome to Appium v1.14.2 [Appium] Appium REST http interface listener started on 0.0.0.0:4723 [Appium] 欢迎使用 Appium v1.14.2 [Appium] Appium REST http 接口监听器开始于 0.0.0.0:4723

this is my BaseClass这是我的基类

package tests;

import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.remote.MobileCapabilityType;

public class BaseClass {


    AppiumDriver<MobileElement> driver;

    @BeforeTest
    public void setup() {

        try {

        DesiredCapabilities caps = new DesiredCapabilities();

        caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "ANDROID");
        caps.setCapability(MobileCapabilityType.VERSION, "6.0.1");
        caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 7");
        caps.setCapability(MobileCapabilityType.UDID, "0911b4aa");
        caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);
   //       caps.setCapability(MobileCapabilityType.APP, "");
        caps.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
        URL url = new URL("http://0.0.0.0:4723/wd/hub");

        driver = new AppiumDriver<MobileElement>(url,caps);


        }catch(Exception  exp) {
            System.out.append("cause is  : "+exp.getCause());
            System.out.append("Message is : "+exp.getMessage());
            exp.printStackTrace();
        }
    }
    @Test
    public void sampleTest() {
        System.out.print("I am running a test");
    }

    @AfterTest
    public void teardown() {
        driver.close();
        driver.quit();

    }

}

This is my POM File...这是我的 POM 文件...

<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>Android_F1_TV</groupId>
        <artifactId>Android_F1_TV</artifactId>
        <version>0.0.1-SNAPSHOT</version>

        <dependencies>

            <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
            <dependency>
                <groupId>io.appium</groupId>
                <artifactId>java-client</artifactId>
                <version>6.1.0</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>3.14.0</version>
            </dependency>

            <!-- https://mvnrepository.com/artifact/org.testng/testng -->
            <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>7.0.0</version>
                <scope>test</scope>
            </dependency>

        </dependencies>

    </project>

The errors returned are.....返回的错误是......

    [RemoteTestNG] detected TestNG version 7.0.0
cause is  : java.lang.reflect.InvocationTargetExceptionMessage is : 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.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'Taylers-MacBook-Pro.local', ip: 'fe80:0:0:0:1c63:8428:5e15:4731%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_221'
Driver info: driver.version: AppiumDriverorg.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.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'Taylers-MacBook-Pro.local', ip: 'fe80:0:0:0:1c63:8428:5e15:4731%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_221'
Driver info: driver.version: AppiumDriver
    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:543)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
    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 tests.BaseClass.setup(BaseClass.java:35)
    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:133)
    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
    at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
    at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
    at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:623)
    at org.testng.TestRunner.beforeRun(TestRunner.java:613)
    at org.testng.TestRunner.run(TestRunner.java:584)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.reflect.InvocationTargetException
    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 io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:185)
    ... 35 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not find 'aapt' in ["/usr/local/share/android-sdk/platform-tools/aapt","/usr/local/share/android-sdk/emulator/aapt","/usr/local/share/android-sdk/tools/aapt","/usr/local/share/android-sdk/tools/bin/aapt"]. Do you have Android Build Tools installed at '/usr/local/share/android-sdk'?
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'Taylers-MacBook-Pro.local', ip: 'fe80:0:0:0:1c63:8428:5e15:4731%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_221'
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not find 'aapt' in ["/usr/local/share/android-sdk/platform-tools/aapt","/usr/local/share/android-sdk/emulator/aapt","/usr/local/share/android-sdk/tools/aapt","/usr/local/share/android-sdk/tools/bin/aapt"]. Do you have Android Build Tools installed at '/usr/local/share/android-sdk'?
    at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
    at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:447:37)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    ... 40 more
I am running a testFAILED CONFIGURATION: @AfterTest teardown
java.lang.NullPointerException
    at tests.BaseClass.teardown(BaseClass.java:51)
    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:133)
    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
    at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
    at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
    at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:623)
    at org.testng.TestRunner.afterRun(TestRunner.java:853)
    at org.testng.TestRunner.run(TestRunner.java:594)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

PASSED: sampleTest

===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
    Configuration Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Passes: 1, Failures: 0, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================

    enter code here

I can see in the error response that AAPT is mentioned and that is to do with the Android SDK.我可以在错误响应中看到提到了 AAPT,这与 Android SDK 有关。 here is my.profile file where my SDK info is stored...这是 my.profile 文件,其中存储了我的 SDK 信息...

Adding path of platform tools folder in path environments variable export PATH="/usr/local/Caskroom/android-sdk/4333796/platform-tools:$PATH"在路径环境变量 export PATH="/usr/local/Caskroom/android-sdk/4333796/platform-tools:$PATH" 中添加平台工具文件夹的路径

Setting PATH for ANDROID_HOME export ANDROID_HOME="/usr/local/share/android-sdk"为 ANDROID_HOME 设置 PATH 导出 ANDROID_HOME="/usr/local/share/android-sdk"

The error seems to be that it does not find the class LoggingHandler .错误似乎是它没有找到 class LoggingHandler That class is usually in the selenium-api dependency. class 通常在 selenium-api 依赖项中。 You can try to use 2.53.1 version instead of 3.4.0.您可以尝试使用 2.53.1 版本而不是 3.4.0。 That version has the missing class.该版本缺少 class。

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-api</artifactId>
    <version>2.53.1</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WebDriverException:无法创建新会话,因为未找到需要HttpClient,InputStream和long的&#39;createSession&#39; - WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found 无法创建新的远程会话。 (应用程序错误) - Unable to create a new remote session. (appium error) 尝试在Oreo设备上创建新的“会话”对象时发生致命错误 - Fatal Error when trying to create new 'Session' object on an Oreo device SetText不可能,因为线程错误 - SetText Impossible because bad thread 如何在spring中新建一个session? - How to create a new session in spring? Kotlin 2 错误:错误:意外标记(使用 ';' 分隔同一行上的表达式)和错误:智能转换为 'Int' 是不可能的,因为 - Kotlin 2 Errors: error: unexpected tokens (use ';' to separate expressions on the same line) AND error: smart cast to 'Int' is impossible, because httpservletrequest - 创建新会话/更改会话ID - httpservletrequest - create new session / change session Id Tomcat始终创建新会话 - Tomcat create always new session 登录后创建新会话 - create new session after login 由于实例是可变属性,因此无法进行智能投射 - smart cast impossible because instance is mutable property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM