执行 TouchAction 的时候出现 WebDriverException. 只出现在安卓机器上,苹果上一切正常。
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.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z'
System info: host: 'sprylabs.local', ip: '2001:1438:4010:2812:0:0:0:ff86', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_91'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.sprylab.appiumtestapp, deviceScreenSize=2560x1600, networkConnectionEnabled=true, noReset=true, warnings={}, databaseEnabled=false, deviceName=CB5A28GNDH, fullReset=false, platform=LINUX, deviceUDID=CB5A28GNDH, appActivity=com.sprylab.purple.android.app.purple.splash.SplashActivity, desired={appPackage=com.sprylab.appiumtestapp, appActivity=com.sprylab.purple.android.app.purple.splash.SplashActivity, noReset=true, newCommandTimeout=300, udid=CB5A28GNDH, platformName=Android, deviceName=SGP712, fullReset=false}, newCommandTimeout=300, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, javascriptEnabled=true, deviceModel=SGP712, udid=CB5A28GNDH, deviceManufacturer=Sony, platformName=LINUX}]
Session ID: 94ad6514-8ace-4918-9016-8e062d594f53
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:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:82)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45)
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:646)
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.sprylab.purple.pages.KioskPage.scrollUpUntilElementDisplayed(KioskPage.java:357)
at com.sprylab.purple.tests.KioskTest.MultiIssueDownloadInSameTime(KioskTest.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at com.sprylab.tools.appium.internal.DeviceRunner$AppiumDriverStatement.evaluate(DeviceRunner.java:269)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at com.sprylab.tools.appium.internal.DeviceRunner$AppUninstallChildrenInvokerStatement.evaluate(DeviceRunner.java:224)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at com.sprylab.tools.appium.AppiumMultiDeviceTestRunner.runChild(AppiumMultiDeviceTestRunner.java:151)
at com.sprylab.tools.appium.AppiumMultiDeviceTestRunner.runChild(AppiumMultiDeviceTestRunner.java:46)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at com.sprylab.tools.appium.AppiumMultiDeviceTestRunner$1.evaluate(AppiumMultiDeviceTestRunner.java:140)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
public void scrollUpUntilElementDisplayed(WebElement element) throws NoSuchElementException {
int windowHeight = driver.manage().window().getSize().height;
int windowWidth = driver.manage().window().getSize().width;
do {
new TouchAction(driver)
.press(windowWidth / 2, windowHeight / 2)
.waitAction(Duration.ofMillis(300))
.moveTo(0, -200)
.release()
.perform();
} while (!element.isDisplayed());
}