Android の実際のデバイスで自動化を実行しています。自動化は、バージョンが 7 未満のデバイス間で正常に機能します。しかし、バージョンが 7 よりも大きいデバイス (Redmi-note4、Redmi 4) で自動化を実行しようとすると、以下のエラーが発生します。
[TestNG] Running:
C:\Users\sandeepraju\AppData\Local\Temp\testng-eclipse-819864143\testng-customsuite.xml
FAILED: newRegistrationIn
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "C:\Users\sandeepraju\AppData\Local\Android\sdk1\platform-tools\adb.exe shell "stop; sleep 2; setprop sys.boot_completed 0; start""
stop: must be root
start: must be root
) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9.96 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'SandeepDell', ip: '192.168.234.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: io.appium.java_client.android.AndroidDriver
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.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:158)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:109)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:39)
at com.gdi.basemodule.LaunchApp.launchApplication(LaunchApp.java:51)
at com.gdi.modules.Modules.newRegistrationIn(Modules.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
以下のコードを参照してください。
public AndroidDriver launchApplication(String appName,ExtentTest testReport) throws MalformedURLException, InterruptedException
{
DesiredCapabilities cap= new DesiredCapabilities();
File appDir=new File("apps");
File app= new File(appDir,appName);
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION,"6.0.1");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Redmi4");
AndroidDriver androidDriver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"),cap);
System.out.println(androidDriver);
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
androidDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
testReport.log(LogStatus.INFO, "Launch application");
if(androidDriver!=null)
{
testReport.log(LogStatus.PASS, "Successfully launched the application");
}
}
自動化アンドロイドリアルデバイス7.0を実行するのを手伝ってください