This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
12 / 28
Jul 2016

No, I don't need to tap on whole element, only on part of it - "Sign Up".
Unfortunately, there is only one way - Dirty solution ((
Thanks everyone!

All locators(resource-id, xpath, name, index, text... ) relates to whole Spannable Text: "You don't have an account? Sign Up".
Can't find the way to tap only on "Sign Up" except of with coordinates. But this is not very good.

Found the Hard way for my case:

//give middle position with respect to height
int y_coodinate = (element.getLocation().getY() + element.getLocation().getY()+element.getSize().height) /2;

//give x - x/10 position with respect to width
int x_coodinate = element.getLocation().getX()+element.getSize().width - (element.getLocation().getX()+ element.getLocation().getX()+element.getSize().width)/10;

driver.tap(1, x_coodinate, y_coodinate, 1000);

sorry in advance but this is total mess :slight_smile:
one line of all your code

   driver.tap(1, (el.getLocation().getX()+el.getSize().getWidth())*9/10, el.getCenter().getY(),200);

Cannot resolve method 'getCenter()'
Nope, it's not working in one line. Maybe I need some extra Library for 'getCenter()' ?

@VolodymyrGlushkov
Hi, why don't you use TouchAction.

TouchAction action = new TouchAction((MobileDriver) driver);
action.tap(x-cordinate,y-cordinate).perform();

You can get these by turn on Pointer location in your device developer settings

public void tapSignUpLink() {
            WebElement element = driver.findElement(By.id("com.qwerty.android:id/label_need_account"));
            driver.tap(1, (element.getLocation().getX()+element.getSize().getWidth())*9/10, element.getCenter().getY(),200);
        }

Actual result:
"Cannot resolve method 'getCenter()'"

Because, I don't know how to get wright x-,y-coordinates of needed element. It should not be hardcore-digit coordinates. It should be some easy formula that works on most of devices with different display sizes.

i was wrong :frowning: it is MobileElement from Appium Java client.

        MobileElement someElement;
        someElement = (MobileElement) driver.findElement(MobileBy.id("test"));
        Point p = el.getCenter();
11 months later

@VolodymyrGlushkov I'm having similar issue... I need to tap on the link "Sign Up" which is part of below element
"You don't have an account? Sign Up".

My complication is that the label "Sign Up" can be on same line or it can be continue to the next line based on screen size.
rest of the label is not tappable

Basically, using x, y may not help... any suggestions on how we can workaround this?

1 month later

@Prashanth if you use latest appium 1.6.5+ just log:

System.out.println(driver.getPageSource());

latest appium can switch to webView itself. if not i will show how to do it later...

I am using 1.4.16.1 (Ohpiuchus) and i have windows 8.1 don't have mac to upgrade to latest appium version

you do not need mac :-). to install latest appium in windows you need:

  1. install nodeJS -> https://nodejs.org/en/1
  2. in command prompt execute:
npm install -g appium@beta

although it's beta - it has tons of improvements. if you doubt you can install previours like:

npm install -g appium@1.6.5

now all is needed to start appium on windows PC is in command line execute "appium" :slight_smile: