If text for an element is not available than scrollTo(xpath) method might be useful.
Just a suggestion.
created
Feb '15
last reply
Feb '15
- 4
replies
- 2.4k
views
- 3
users
- 3
likes
If text for an element is not available than scrollTo(xpath) method might be useful.
Just a suggestion.
Yes I agree there should be some method where we can use xpath and scroll in java client itself. But You can edit and use below code for xpath as a workaround.
**public WebElement scroll(String keyword)
{
HashMap scrollObject = new HashMap();
RemoteWebElement element = (RemoteWebElement) driver.findElementByAndroidUIAutomator(
"new UiSelector().className(\"android.widget.ListView\")");
JavascriptExecutor js = (JavascriptExecutor) driver;
String webElementId = ((RemoteWebElement) element).getId();
System.out.println(webElementId);System.out.println(element);
scrollObject.put("text", keyword);
scrollObject.put("element", webElementId);
js.executeScript("mobile: scrollTo", scrollObject);
return element;
}**
Very Nice Idea.. @Mayuresh_Shirodkar. because ScrollTo(text) is taking so much of time and also it doesn't support for move to a particular element..