Abhinav Aradhya
Abhinav Aradhya

Reputation: 51

Can bounds(co-ordinates) be used while identifying an element on an Android App?

Can something like this work? Well, it's not working for me. Guys, what's the right-est way of making it work? Need Help (Appium version - 1.4.0.0 and Selenium 2.4.5)

dr.findElement(By.xpath("//android.widget.ImageButton[@bounds='[9,288][144,318]']"))
  .click();

Upvotes: 5

Views: 11414

Answers (2)

user17715574
user17715574

Reputation: 1

This is simple. But yet helped me to swipe from right to left, for what I was roaming all over the internet.

TouchAction t = new TouchAction(dr);
WebElement from = dr.findElementByXPath("//android.widget.Button[@bounds='[354,2232][539,2263]']");
WebElement to = dr.findElementByXPath("//android.widget.Button[@bounds='[0,2232][181,2263]']");
t.longPress(longPressOptions().withElement(element(from)).withDuration(ofSeconds(2))).moveTo(element(to)).release().perform();

Upvotes: 0

jammer
jammer

Reputation: 91

Try below code, it works for me...

WebElement abc = driver.findElement(By.xpath ("//android.widget.ImageButton[@bounds='[9,288][144,318]']"))

abc.click();

Upvotes: 9

Related Questions