简体   繁体   English

如何在JAV中使用appium驱动程序结束滚动动作?

[英]How to end the scroll action using appium driver in jav?

  1. I am writing automation test case for iOS app using appium and java. 我正在使用appium和java为iOS应用程序编写自动化测试用例。
  2. I need to do scroll action, I have tried with below code for scroll action. 我需要做滚动动作,我已经尝试使用下面的代码进行滚动动作。
  3. I need to scroll till the particular web element and then i need to assert that particular element. 我需要滚动到特定的Web元素,然后再声明该特定的元素。
  4. Below code scroll till the end of the page, after it reached to the end of the page, it tries to scroll down, so it throws error message. 下面的代码滚动到页面末尾,到达页面末尾后,它尝试向下滚动,因此抛出错误消息。
  5. I don't know how to end the scroll action, if particular web element is present means, I need to end the scroll action. 我不知道如何结束滚动动作,如果存在特定的Web元素,则需要结束滚动动作。

      while(AppiumHelper.isElementPresent(driver,By.name("Comment")) == false){ System.out.println("1......"); WebElement element = driver .findElementByName("save_button"); JavascriptExecutor js = (JavascriptExecutor) driver; HashMap<String, String> scrollObjects = new HashMap<String, String>(); scrollObjects.put("direction", "down"); scrollObjects.put("element", ((RemoteWebElement) element).getId()); js.executeScript("mobile: scroll", scrollObjects); } 

You can use Xpath for locating the last object on that page/hierarchy. 您可以使用Xpath在该页面/层次结构上定位最后一个对象。 The xpath to last element can be generated like- 到最后一个元素的xpath可以生成为-

("Your_Object_Xpath")[1]/../*[last()] (“ Your_Object_Xpath”)[1] /../* [last()]

Give this object's visibility as a break parameter for your scrolling loop. 将此对象的可见性作为滚动循环的break参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM