gpt4 book ai didi

java - 返回错误 :java. lang.SecurityException:在 appium 中使用 touchaction 类时,注入(inject)到另一个应用程序需要 INJECT_EVENTS 权限

转载 作者:行者123 更新时间:2023-11-29 07:27:48 25 4
gpt4 key购买 nike

返回错误:java.lang.SecurityException:在 appium 中使用 touchaction 类时注入(inject)到另一个应用程序需要 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(); 

下面是堆栈跟踪

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调试安全设置)。附上引用图片。 enter image description here

关于java - 返回错误 :java. lang.SecurityException:在 appium 中使用 touchaction 类时,注入(inject)到另一个应用程序需要 INJECT_EVENTS 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48041301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com