AndroidスタジオでAppium + WebDriverを使用してAndroidエミュレータ用の簡単な電卓テストを実行しています。 Appium ServerとAndroid Emulatorを手動で起動し、TestNG.xmlを使用してテストを実行しています。ここでAppiumエラー:Logcatのキャプチャに失敗しました:ENOENTをAndroidスタジオで作成
は私のサンプルwebdriverをコードである -
package com.example.user.mysampleapp2;
/**
* Created by CParmar on 14-09-2017.
*/
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.testng.annotations.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
public class SampleTests {
public WebDriver driver;
@BeforeClass
public void setUp() throws MalformedURLException {
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();
// Set android deviceName desired capability. Set your device name.
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus_6_API_25");
// Set BROWSER_NAME desired capability. It's Android in our case here.
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Android");
// Set android VERSION desired capability. Set your mobile device's OS version.
capabilities.setCapability(MobileCapabilityType.VERSION, "7.1.1");
// Set android platformName desired capability. It's Android in our case here.
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
// Set android appPackage desired capability. It is
// com.android.calculator2 for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appPackage", "com.android.calculator2");
// Set android appActivity desired capability. It is
// com.android.calculator2.Calculator for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
// Created object of RemoteWebDriver will all set capabilities.
// Set appium server address and port number in URL string.
// It will launch calculator app in android device.
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@Test
public void testFirstCalculator() {
// Click on DELETE/CLR button to clear result text box before running test.
driver.findElements(By.xpath("//android.widget.Button")).get(0).click();
// Click on number 2 button.
driver.findElement(By.name("7")).click();
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
}
@AfterClass
public void End() {
driver.quit();
}
}
私は、Android Studioからこれを実行すると、私はAppiumエラーの下に取得します。
Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 23 --automation-name Appium --log-no-color info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d) info: Appium REST http interface listener started on 127.0.0.1:4723 info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"} info: Console LogLevel: debug info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.calculator2","appActivity":"com.android.calculator2.Calculator","browserName":"Android","platformName":"Android","deviceName":"Nexus_6_API_25","version":"7.1.1"},"requiredCapabilities":{},"capabilities":{"desiredCapabilities":{"appPackage":"com.android.calculator2","appActivity":"com.android.calculator2.Calculator","browserName":"Android","platformName":"Android","deviceName":"Nexus_6_API_25","version":"7.1.1"},"requiredCapabilities":{},"alwaysMatch":{"browserName":"Android","platformName":"Android"},"firstMatch":[]}} info: Client User-Agent string: Apache-HttpClient/4.5.3 (Java/1.8.0_131) info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device info: [debug] Creating new appium session 42818f6f-0677-486a-bc53-efa31009bbe7 info: Starting android appium info: [debug] Getting Java version info: Java version is: 1.8.0_131 info: [debug] Checking whether adb is present warn: The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb. info: [debug] executing cmd: where adb info: [debug] Using adb from C:\Users\CParmar\AppData\Local\Android\sdk\platform-tools\adb.exe
warn: No app capability, can't parse package/activity info: [debug] Using fast reset? true info: [debug] Preparing device for session info: [debug] Not checking whether app is present since we are assuming it's already on the device info: Retrieving device info: [debug] Trying to find a connected android device info: [debug] Getting connected devices... info: [debug] executing cmd: "C:\Users\CParmar\AppData\Local\Android\sdk\platform-tools\adb.exe" devices info: [debug] 1 device(s) connected info: Found device emulator-5554 info: [debug] Setting device id to emulator-5554 info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5) info: [debug] executing cmd: "C:\Users\CParmar\AppData\Local\Android\sdk\platform-tools\adb.exe" -s emulator-5554 wait-for-device info: [debug] executing cmd: "C:\Users\CParmar\AppData\Local\Android\sdk\platform-tools\adb.exe" -s emulator-5554 shell "echo 'ready'" info: [debug] Starting logcat capture error: Logcat capture failed: spawn "C:\Users\CParmar\AppData\Local\Android\sdk\platform-tools\adb.exe" ENOENT info: [debug] Stopping logcat capture
私は、フォーラムで利用可能なすべてのポストを経てもAndroidのメーカーの実行構成(Android_Home)でSDKのパスでANDROID_HOME変数を設定しています。それでも私はこのエラーを受けています。
助けが必要ですか?エラーログから
おかげで、 Chandresh Parmar
すべて
x
マークと幸運を修正します私のマシンとAndroid StudioにインストールされたSDK。下の画像を参照してください。 –