Here I am mentioning two solution that I tried whereas both are not working, please let me know what is the right work around. I am trying to implement swipe functionality using a specific xpath
Following are the ways with which I have tried to implement with various ways but none of them are working, Please give me guidance to reach the solution.
Solution1
if(objCommon.scrollTo("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]"))
driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]")).click();
//Locate the swipe_option
WebElement swipe_option= driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]"));
// get location of swipe_option from left
int start=swipe_option.getLocation().get:@);
System.out.println("Startpoint - " + start);
//get location of swipe_option from top
int y=swipe_option.getLocation().getY();
System.out.println("Yaxis - "+ y);
//Get total width of swipe_option
int end=start + swipe_option.getSize().getWidth();
System.out.println("End point - "+ end);
TouchAction action=new TouchAction((IOSDriver)driver);
//move slider to 70% of width
int moveTo=(int)(end*(0.7));
action.longPress(start,y).moveTo(moveTo,y).release().perform();
Issues-: Here the problem which I have encountered is, I need to swipe from right to left i.e. from 280 to 0 (X axis)
But I am getting an exception: point is not within the bounds of the screen.
I tried with different coordinates too.
Solution2
Dimension dimesions=driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]")).getSize();
System.out.println("Width : "+dimesions.width);
System.out.println("Height : "+dimesions.height);
Point point=driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[4]")).getLocation();
System.out.println("X Position : "+point.x);
System.out.println("Y Position : "+point.y);
System.out.println(point.x * 0.80);
int strty = (int) (point.y );
((IOSDriver)driver).swipe(200, strty,10, strty, 3000);
Issues-: The above method also doesn’t swipe, It keep remain same. This solution works for Vertical swipe not in Horizontal.