Hello,
I am using android mobile app in my project which is Cordova based. While going by your tutorial , I used swipe horizontal and vertical code but its not working in my application . My Eclipse shows error in act asking it to be used as a local variable but in code provided by you its nothing like that . Later also when i fix this code seems not be working in vertical and horizontal scrolling . Please provide solution or any working code .
I can screen share you in case of troubleshoot .
swipe commands or vertical scroll
/*
Dimension dim = driver.manage().window().getSize();
int width = dim.width;
int height = dim.height;
System.out.println("Width - "+ width);
System.out.println("Height - "+ height);
int middleX = width/2;
int startY = (int)(height * .8);
int endY = (int)(height * .2);
act
.press(PointOption.point(middleX,startY))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(3)))
.moveTo(PointOption.point(middleX,endY))
.release()
.perform();
*/
Horizontal scrolling
*/
List<AndroidElement> elements = driver.findElements(By.xpath("//android.widget.ImageView[@resource-id='com.makemytrip:id/program_img']"));
System.out.println("Total Elements "+ elements.size());
AndroidElement toElement = elements.get(0);
AndroidElement fromElement = elements.get(1);
int centerY = fromElement.getLocation().y + (fromElement.getSize().height/2);
int startX= fromElement.getLocation().x;
int endX= toElement.getLocation().x;
act
.press(PointOption.point(startX,centerY))
.waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3)))
.moveTo(PointOption.point(endX,centerY))
.release()
.perform();
Instructor
Ashish Thakur Replied on 30/04/2021
act asking it to be used as a local variable
Where have you initialized act