在android模擬器上執行我的appium代碼時發生意外錯誤


0

錯誤"處理該命令時發生未知的服務器端錯誤。原始錯誤:無法初始化檢測過程。請確保被測應用程序不會崩潰並調查logcat輸出。"

代碼:

import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;

public class mobileAutomation {
    @SuppressWarnings("unused")
    public static void main(String[] args) throws MalformedURLException {
        // TODO Auto-generated method stub
        DesiredCapabilities dcap = new DesiredCapabilities();
        dcap.setCapability(MobileCapabilityType.DEVICE_NAME, "emulator-5554");
        dcap.setCapability(MobileCapabilityType.PLATFORM_NAME,"android");
        dcap.setCapability("appPackage", "com.microsoft.teams");
        dcap.setCapability("appActivity", "com.microsoft.skype.teams.Launcher");
        dcap.setCapability("noReset", "true");
        //dcap.setCapability("automationName", "UiAutomator1");
        AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), dcap);

    }

}```
0

use UiAutomator2 and incluse Android Version

caps.setCapability("platformVersion","4.3");

also make sure appium server is started before running your tests