Thanks a lot buddy it worked;)
For text it worked but when i use id im getting error because most of the elements has id
getDriver().findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().resourceIdMatches(“com.test:id/rvDeals”)).scrollIntoView(”
+ “new UiSelector().text(”"+text+""));")) // (in text how can we pass id)
can u suggest for by using id
in official documentation they have given java script executor but is not working
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put(“direction”, “down”);
scrollObject.put(“element”, ((RemoteWebElement) element).getId());
js.executeScript(“mobile: scroll”, scrollObject);
https://discuss.appium.io/t/is-javascriptexecutor-works-for-appium/3597/8 but this is for co-ordinates
For horizontal scroll/swipe i have tried the following but its clicking on the element instead of swipe may be because of the perform action
public void horizontalScroll()
{
TouchAction action = new TouchAction(getDriver());
int startY = mhpageobjects.swipeWeekenedtreats.getLocation().getY() + (mhpageobjects.swipeWeekenedtreats.getSize().getHeight() / 2);
int startX = mhpageobjects.swipeWeekenedtreats.getLocation().getX() + (mhpageobjects.swipeWeekenedtreats.getSize().getWidth() / 2);
int endX = mhpageobjects.swipeWeekenedtreats.getLocation().getX() + (mhpageobjects.swipeWeekenedtreats.getSize().getWidth() / 2);
int endY = mhpageobjects.swipeWeekenedtreats.getLocation().getY() + (mhpageobjects.swipeWeekenedtreats.getSize().getHeight() / 2);
action.press(startX, startY).waitAction().moveTo(endX, endY).release().perform();
}
Can u suggest a way to swipe horizontal it would be of great help