当我在使用 Appium 时运行我的 testNG 时应用程序崩溃 [英] Application crash at the moment i run my testNG while using Appium

查看:33
本文介绍了当我在使用 Appium 时运行我的 testNG 时应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我的代码在这里配置正确:

I have a problem every thing is right configured here my code :

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Newlook_1 {

    AndroidDriver<AndroidElement> driver;

    File path = new File(
            "/home/emna/Téléchargements/AutomationFiles/app-debug.apk");

    @BeforeClass
    public void setUp() throws MalformedURLException {

        System.out.println("app Dir.--->" + path);

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "SM-G531H");
        capabilities.setCapability("version", "5.1.1");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("device", "Android");
        capabilities.setCapability("platformVersion", "platform");
        capabilities.setCapability("udid", "***********");
        capabilities.setCapability("app", path.getAbsolutePath());
        capabilities.setCapability("appPackage", "com.bulldozer.newlook");
        capabilities.setCapability("appActivity", "com.bulldozer.newlook.activities.SplashActivity");
        capabilities.setCapability("noReset", "false");
        driver = new AndroidDriver<AndroidElement>(new URL(
                "http://127.0.0.1:4723/wd/hub"), capabilities);
        driver.manage().timeouts().implicitlyWait(1500, TimeUnit.SECONDS);


    }

    @Test
    public void Test1() throws InterruptedException {

        driver.wait(10000);
        System.out.println("newlook-tutoriel");
        driver.findElement(By.id("skip")).click();
        System.out.println("newlook-welcome");
        driver.wait(1000);
        driver.findElement(By.id("btn_signin_welcome")).click();
        System.out.println("newlook-Me connecter");
        driver.findElement(By.id("input_email")).sendKeys("e@e.emmna.com");
        driver.findElement(By.id("input_password")).sendKeys("00000000");
    }

    @AfterClass
    public void tearDown() {
        driver.quit();

    }

}

当我使用 npm 运行 appium 时:

while i run appium with npm using :

appium -a 127.0.0.1

看起来应用程序启动一段时间后崩溃了!

It looks like the application start after a while it get crashed !

这里是我的 appium 日志文件,它告诉我在 java 中添加了一个 IllegalMonitorStateException :

Here my appium log file it tells that there is a IllegalMonitorStateException in java add to that :

[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","********","shell","am","force-stop","com.bulldozer.newlook"]
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","************","shell","input","keyevent",3]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 12.803
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","******","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/home/emna/Android/Sdk/platform-tools/adb' with args: ["-P",5037,"-s","4b13731fdfdd824e","shell","am","force-stop","io.appium.unlock"]
[debug] [Logcat] Stopping logcat capture
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[Appium] Removing session 7fe5b58a-8d00-4f8a-9aa8-f61f2d374eb6 from our master session list
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[debug] [MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/7fe5b58a-8d00-4f8a-9aa8-f61f2d374eb6 200 2319 ms - 76 

我该如何解决这个问题?我应该重新启动远程会话吗?预先感谢您提出的任何解决方案:)

How can i solve this problem? shall i restart the remote session ? Thanks in advance for any solution you propose :)

推荐答案

我只是通过删除来解决它:driver.wait(10000);

I solve it just by removing : driver.wait(10000);

这篇关于当我在使用 Appium 时运行我的 testNG 时应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆