java 使用 Appium 向下滚动时“处理命令时发生未知的服务器端错误”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28022852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"An unknown server-side error occurred while processing the command" while doing scroll down using Appium
提问by testing
I have used following code to scroll down
我使用以下代码向下滚动
WebElement elementToScroll = driver.findElement(By.id("id"));
scrollDown(elementToScroll, "Max Notifications Per Instance", driver);
((JavascriptExecutor ) driver).executeScript ("mobile: scroll", :direction => 'down');
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
scrollObject.put("element", ((RemoteWebElement) elementToScroll).getId());
scrollObject.put("text", elementToScroll.getText());
js.executeScript("mobile: scroll", scrollObject);
and in setup I have changed WebDriver driver
into driver = new RemoteWebDriver();
because to hookup my script with sauce lab
在设置中,我已更改WebDriver driver
为driver = new RemoteWebDriver();
因为将我的脚本与酱汁实验室连接起来
Everything is working properly but when I try to do scrolling its giving error
一切正常,但是当我尝试滚动时出现错误
An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)(..)
处理命令时发生未知的服务器端错误。(警告:服务器没有提供任何堆栈跟踪信息)(..)
Please let me know if I am doing something wrong here.
如果我在这里做错了什么,请告诉我。
回答by jon_two
I have been getting the unknown server-side error while writing automation tests with Appium and it is usually due to an element on the page - like a date picker or autocomplete menu - getting in the way of the element you are trying to click.
在使用 Appium 编写自动化测试时,我遇到了未知的服务器端错误,这通常是由于页面上的元素(例如日期选择器或自动完成菜单)妨碍了您尝试单击的元素。
Make sure your scroll object is visible and there is nothing overlaying it. You could always use a fluent waitto give any other elements time to finish what they are doing and get out of the way.
确保您的滚动对象可见并且没有任何内容覆盖它。你总是可以使用流畅的等待来给任何其他元素时间来完成他们正在做的事情并让开。
回答by Swapnil Kotwal
WebElement element = driver.findElement(By.id("my-id"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
// actions.click();
actions.perform();
回答by testing
I have used same code to scroll just change element 'elementToScroll'. I have used element for which scrollable value is 'true'
我使用相同的代码来滚动只是更改元素“elementToScroll”。我使用了可滚动值为“true”的元素