Thanks @Aleksei for your reply.
@Telmo_Cardoso could you please tell me about Page Scroll up and Page Scroll Down by same format, it would be more helpful for me. Thanks in advance.
As you said, it is the same format... You just exchange height for width
public static void swipeVertical(AppiumDriver driver, double startPercentage, double finalPercentage, double anchorPercentage, int duration) throws Exception {
Dimension size = driver.manage().window().getSize();
int anchor = (int) (size.width * anchorPercentage);
int startPoint = (int) (size.height * startPercentage);
int endPoint = (int) (size.height * finalPercentage);
new TouchAction(driver).press(anchor, startPoint).waitAction(duration).moveTo(anchor, endPoint).release().perform();
//In documentation they mention moveTo coordinates are relative to initial ones, but thats not happening. When it does we need to use the function below
//new TouchAction(driver).press(anchor, startPoint).waitAction(duration).moveTo(0,endPoint-startPoint).release().perform();
}
swipeVertical(driver,0.9,0.1,0.5,3000);
@Telmo_Cardoso, One more question please, How I can verify toast message ? I'm using java-client 4.1.2
@Telmo_Cardoso, Could you please tell me how to hide the android keyboard.
I have tried this one: driver.hideKeyboard()
but it's not working.
Currently I'm using: driver.navigate().back();
but I think it's not the proper way.
could you please tell me the better way i'm using java-client 4.1.2
I'm waiting for your ans please @Telmo_Cardoso
@Telmo_Cardoso in my case, I need to swipe a row to left to view hidden button on right side of it.
I tried your solution but instead of press event, I see tap event happening on row.
I'm not sure what may be going wrong, even I tried longPress instead of press but no luck yet.
Can you please refer to below method and review if it has some issue ?
WebElement rowToSlide = driver.findElement(By.xpath("//XCUIElementTypeApplication[1]//XCUIElementTypeTable[1]/XCUIElementTypeCell[1]"));
Dimension size = rowToSlide.getSize();TouchAction swipe = new TouchAction(driver).press(rowToSlide, size.width / 2 + 50 , size.height / 2).waitAction(1000) .moveTo(rowToSlide, 100, size.height / 2).release().perform();
@Telmo_Cardoso, I have created a new issue, could you please ans my question:
Hi @Telmo_Cardoso, i tried this code for Swipe Up, After running, the TestNG test result indicates passed but on the actual device is not swiped. Please Help me. Thanks
Looping @Al_Imran for this… How did you fixed yours? Thanks
One more thing, you can enable touch and pointer option for observing touch action, From android mobile Settings > Developer option > Input > Enable Pointer location and Show touches, observe the touch action and change the start point / end point / time duration from swipeVertical(driver,0.9,0.1,0.5,3000);
as you need.
Here’s how I placed it. I just copied the code above.
I called the method to my test.java class:
with Regards to Settings, I don’t have also the 'Enable Pointer location and Show touches ’ option. I’m currently using Samsung Galaxy S8. Thank you. @Al_Imran
I have tried this but no effect takes place
I have 1 question how u get the co-ordinates
0.9,0.1,0.5,3000
And also when I tried this
Dimension dim= SwipeHomeButton.getSize();
int height= dim.getHeight();
int width = dim.getWidth();
int y = (int)(height*.20);
int startx=(int)(width*.75);
int endx=(int)(width*.35);
driver.swipe(startx, y, endx, y,500);
new TouchAction(driver).press(y, startx).waitAction(5000).moveTo(y, endx).release().perform();
It pulled from the top on my android phone
It looks like it is not able to get the proper co-ordinates
Can u plzz help me with this