2017-12-31 38 views
1
にtouchactionクラスを使用している間、別のアプリケーションに注入するINJECT_EVENTS権限が必要です

返されたエラー:java.lang.SecurityException:appiumにtouchactionクラスを使用している間、他のアプリケーションへの注入は、INJECT_EVENTSの許可が必要返されるエラー:java.lang.SecurityExceptionが:appium

try { 
    logger.info("Launching the app"); 
    driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps); 
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 
    logger.info("Value of driver ----" +driver); 
    MobileElement seekbar=driver.findElementByClassName("android.widget.SeekBar"); 
    int startX=seekbar.getLocation().getX(); 
    int startY=seekbar.getLocation().getY(); 
    int endX=(startX+seekbar.getSize().getWidth()); 
    TouchAction action=new TouchAction(driver); 
    action.longPress(startX, startY).moveTo((int) (endX*0.5), startY).release().perform();  
} catch (MalformedURLException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 

この行でエラーを取得中...以下

action.longPress(startX, startY).moveTo((int) (endX*0.5), startY).release().perform(); 

とは、スタックトレース

Exception in thread "main" org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 0 milliseconds 
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z' 
System info: host: 'sysadmin-ThinkPad-L440', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-30-generic', java.version: '1.8.0_151' 
Driver info: io.appium.java_client.android.AndroidDriver 
Capabilities {appActivity: nu.lower.brightness.SplashS..., appPackage: nu.lower.brightness, browserName: android, databaseEnabled: false, desired: {appActivity: nu.lower.brightness.SplashS..., appPackage: nu.lower.brightness, browserName: android, deviceName: MauryaJi, newCommandTimeout: 120, noReset: true, platform: ANDROID, platformName: Android, udid: 93ffd01a0803, version: 7.0 NRD90M}, deviceManufacturer: Xiaomi, deviceModel: Redmi Note 4, deviceName: 93ffd01a0803, deviceScreenSize: 1080x1920, deviceUDID: 93ffd01a0803, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, newCommandTimeout: 120, noReset: true, platform: ANDROID, platformName: ANDROID, platformVersion: 7.0, takesScreenshot: true, udid: 93ffd01a0803, version: 7.0 NRD90M, warnings: {}, webStorageEnabled: false} 
Session ID: 45824a17-fa92-4570-b5e4-a09c578b3367 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) 
    at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40) 
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80) 
    at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) 
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
    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:325) 
    at com.appium.test.TestCase1.brightnessControl(TestCase1.java:125) 
    at com.appium.test.ExecuteTest.main(ExecuteTest.java:11)`` 
です

答えて

0

私のモバイルに開発者オプションを訪問して自分の問題を解決し、自分のデバイスのセキュリティ設定を有効にしました コーディングの問題ではありませんでした。 携帯電話で設定を変更しました。 設定 - >追加設定 - >開発者オプション - >(USBデバッグセキュリティ設定)。 参考に画像が添付されています。 enter image description here

関連する問題