InvocationTargetExceptionMessage: невозможно создать новый сеанс из-за ошибки «createSession» - PullRequest
0 голосов
/ 23 сентября 2019

Я пытаюсь настроить простую платформу селена для запуска из Appium.Тест должен просто открыть Chrome на устройстве Android.Я создал свой базовый класс, который, к сожалению, возвращает ошибку

Я изначально думал, что эта проблема связана с URL-адресом http://0.0.0.0:4723/wd/hub,. Я изменил его, но ошибка по-прежнему отображалась.Я также изменил свой клиент версии Java, но каждый раз, когда я делаю это, появляется другая ошибка !!

Моя версия Appium следующая:

[Appium] Добро пожаловать в Appium v1.14.2 [Appium] Прослушиватель http интерфейса Appium REST запущен 0.0.0.0:4723

это мой 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();

    }

}

Это мой файл 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>

Возвращенные ошибки: .....

    [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

В ответе на ошибку я вижу, что упоминается AAPT и чтоделать с Android SDK.Вот мой файл .profile, в котором хранится информация о моем SDK ...

Добавление пути к папке инструментов платформы в пути среды переменная export PATH = "/ usr / local / Caskroom / android-sdk / 4333796 / platform-tools: $ PATH "

Установка PATH для экспорта ANDROID_HOME ANDROID_HOME =" / usr / local / share / android-sdk "

1 Ответ

0 голосов
/ 23 сентября 2019

Кажется, ошибка в том, что он не находит класс LoggingHandler.Этот класс обычно находится в зависимости от selenium-api.Вы можете попробовать использовать версию 2.53.1 вместо 3.4.0.В этой версии отсутствует класс.

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