iam trying to tap on an element using pointoption and it is not working
iam using the latest verison of Appium v1.10.0
below is the code in the page object
TouchAction t =new TouchAction(driver);
PointOption point=new PointOption();
public void scroll_to_orders()
{
new TouchAction(driver).tap(PointOption.point(299,437)).release().perform();
}
below is the import file
import io.appium.java_client.touch.offset.PointOption;
make sure you have the latest java client.
A better approach would be to get the center the element and tap on it
org.openqa.selenium.Point centerOfElement = element.getCenter();
new TouchAction<>(driver).tap(point(centerOfElement.x, centerOfElement.y)).perform();
Why don’t you tap directly on the element?
public void tap(MobileElement yourElement) {
new TouchAction<>(driver).tap(tapOptions().withElement(element(yourElement))).perform();
}
how to get the center of the element ?
iam using UIAUTOMATOR to find the co ordinates
org.openqa.selenium.Point centerOfElement = element.getCenter();
new TouchAction<>(driver).tap(point(centerOfElement.x, centerOfElement.y)).perform();
will the above syntax work? bcse i can see the import file and the element combined , iam new to appium. plse can u explain me and help me?
org.openqa.selenium.Point centerOfElement
Try this
public void pressByCoordinates (int x, int y, long seconds) {
new TouchAction(driver)
.press(point(x,y))
.waitAction(waitOptions(ofSeconds(seconds)))
.release()
.perform();
}
i tried what you gave and it is not clicking the co ordinates
POM code
public void scroll_to_orders(int x, int y, long seconds)
{
((AndroidDriver)driver).findElementByAndroidUIAutomator(“new UiScrollable(new UiSelector()).scrollIntoView(text(“Orders”));”);
// t.tap(new PointOption().withCoordinates(359, 485)).perform();
new TouchAction(driver).press(point(299,437)).waitAction(waitOptions(ofSeconds(seconds))).release().perform();
// new TouchAction(driver).tap(PointOption.point(299,437)).release().perform();
}
test case
@Test
public void c_orders()
{
object = new PageObjects(driver);
object.scroll_to_orders(299, 437,10);
in my PageObject code i have swiped and tried to click using co ordinates in the scroll_to_orders() method
Let me explain the requirement fully
1: launch the app
2: after launching click on the “skip the tour”
3 : Click on internal user
4 ; enter the credentials
5 : click the sync button on the top right
6 : after the sync we can see list page
7 : scroll to orders
8 : click orders
The problem here is in the list page after synce we don’t have name, id and any other attributes , we have only common class name.
Need to click on orders
can you plse help