Исправьте эту ошибку приложения: «Сеанс либо завершен, либо не запущен» - PullRequest
0 голосов
/ 05 мая 2019

Я получаю этот код ошибки и не могу найти какое-либо решение:

Exception in thread "main" org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started

Я попытался найти какую-то информацию в Интернете, но я не нашел ни одной по своей проблеме.

Я пытаюсь автоматизировать небольшую часть игры Epic Seven, используя appium и некоторые жестко закодированные переменные.Я не знаю, есть ли какие-либо проблемы в моих возможностях, но я думаю, что нет, потому что это прекрасно работает на сессии инспектора.Поэтому я думаю, что проблема в моем коде, логике или установке моих драйверов.

Мой код:

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.touch.offset.PointOption;

public class main {
    public static DesiredCapabilities init() {
//        "platformName": "Android",
//        "deviceName": "HUAWEI P10",
//        "appPackage": "com.stove.epic7.google",
//        "appActivity": "kr.supercreative.epic7.AppActivity",
//        "noReset": true,
//        "skipDeviceInitialization": true,
//        "skipServerInstallation": true

        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("deviceName", "HUAWEI P10");
        caps.setCapability("udid", "6PQ0217829002238"); //Give Device ID of your mobile phone
        caps.setCapability("platformName", "Android");
        caps.setCapability("platformVersion", "8.0.0");
        caps.setCapability("appPackage", "com.stove.epic7.google");
        caps.setCapability("appActivity", "kr.supercreative.epic7.AppActivity");
        caps.setCapability("noReset", "true");
        caps.setCapability("skipServerInstallation", true);
        caps.setCapability("clearSystemFiles", false);

        return caps;
    }


    public static void main(String[] args) throws InterruptedException {
        Scanner input = new Scanner(System.in);


        try {
            AppiumDriver<MobileElement> mygame = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), init());
            int x = 1;

            while(x != -1) {
                x = input.nextInt();
                TouchAction touchAction = new TouchAction(mygame);

                for(int i = 0; i < x; i++) {
                    //select team + supp
                    touchAction.tap(new PointOption().withCoordinates(1400, 950)).perform();
                    //start quest
                    touchAction.tap(new PointOption().withCoordinates(1400, 950)).perform();
                    //buy energy
                    touchAction.tap(new PointOption().withCoordinates(1076, 772)).perform();
                    //start quest again if energie empty
                    touchAction.tap(new PointOption().withCoordinates(1400, 950)).perform();
                    //wait for finishing mission
                    for(int j = 0; j < 4;j++) {
                        Thread.sleep(1000 * 30 * 2);
                        touchAction.tap(new PointOption().withCoordinates(1400, 950)).perform();
                    }

                    Thread.sleep(1000 * 60 * 2);
                    //clear stage tap anywhere
                    touchAction.tap(new PointOption().withCoordinates(1400, 950)).perform();
                    //confirm mvp
                    touchAction.tap(new PointOption().withCoordinates(1740, 994)).perform();
                    //play again
                    touchAction.tap(new PointOption().withCoordinates(1740, 994)).perform();                

                }





            }

        } catch (MalformedURLException e) {
            System.out.println(e.getMessage());
        }       

    }

}

А вот мой журнал ошибок в Eclipse:

Exception in thread "main" org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'LAPTOPMARTIN', ip: '192.168.178.21', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: kr.supercreative.epic7.AppA..., appPackage: com.stove.epic7.google, clearSystemFiles: false, databaseEnabled: false, desired: {appActivity: kr.supercreative.epic7.AppA..., appPackage: com.stove.epic7.google, clearSystemFiles: false, deviceName: HUAWEI P10, noReset: true, platformName: android, platformVersion: 8.0.0, skipServerInstallation: true, udid: 6PQ0217829002238}, deviceManufacturer: HUAWEI, deviceModel: VTR-L09, deviceName: 6PQ0217829002238, deviceScreenSize: 1080x1920, deviceUDID: 6PQ0217829002238, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, platform: LINUX, platformName: Android, platformVersion: 8.0.0, skipServerInstallation: true, takesScreenshot: true, udid: 6PQ0217829002238, warnings: {}, webStorageEnabled: false}
Session ID: 1341c917-75bc-4988-a5bf-854c9affb81f
    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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    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 io.appium.java_client.PerformsTouchActions.performTouchAction(PerformsTouchActions.java:41)
    at io.appium.java_client.TouchAction.perform(TouchAction.java:187)
    at test.main.main(main.java:65)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...