簡體   English   中英

返回錯誤:java.lang.SecurityException:在appium中使用touchaction類時,注入到另一個應用程序需要INJECT_EVENTS權限

[英]returned error:java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission while using touchaction class in appium

返回錯誤:java.lang.SecurityException:在appium中使用touchaction類時,注入到另一個應用程序需要INJECT_EVENTS權限

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(); 

下面是stacktrace

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)``

我通過訪問手機的開發人員選項解決了我的問題,並啟用了設備的安全設置。這不是編碼問題。 我已經更改了手機中的設置。 設置->其他設置->開發人員選項->(“ USB調試安全性”設置)。 供參考圖像。 在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM