Hi Aleksei!
How can i click on those links one by one as it doesn’t have any id’s
please help me how to resolve it.
Thanks in advance.
Hi Aleksei!
How can i click on those links one by one as it doesn’t have any id’s
please help me how to resolve it.
Thanks in advance.
@Prashanth try on same screen:
@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:
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 [email protected]
now all is needed to start appium on windows PC is in command line execute “appium”
Ok i will try it. and let you know.
it prints the page source as below how can i find elements to click on those links please help me.
<?xml version="1.0" encoding="UTF-8"?>Hi VolodymyrGlushkov,
Can you please share me your code to click on Text link inside a TextView. Im facing similar kind of issue, i tried with below snippet. It doesnt work.
Element = Please click on the Our website using ‘Click here’
locator id = com.demoApp.sampleDemoApplication:id/text_title
*Click here has the link, which i need to click on from script.
Point point = element.getLocation();
size = getIOSDriver().manage().window().getSize();
int x = point.x + 1;
int y = point.y + element.getSize().getHeight() - 1;
TouchAction touchAction = new TouchAction(getIOSDriver());
touchAction.tap(x, y).perform();
Much appreciated for your response.
Thanks
How to do driver.tap ?
do I need to use touchActions?
@Priya_Khiwal tons of examples :- > https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/android/AndroidTouchTest.java
AndroidDriver, where does this come from? I am not able to resolve this dependency…
Right from java client -> https://github.com/appium/java-client/blob/master/src/main/java/io/appium/java_client/AppiumDriver.java
@Aleksei tap method could not be found using driver.tap and also referred the one which you had posted here still no luck.
Tried below code,
Getting error --> org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
Point center1 = driver.findElementById("new_order").getCenter();
TouchAction startStop = new TouchAction(driver)
.tap(point(center1.x, center1.y))
.tap(element(driver.findElementById("new_order"), 5, 5));//Getting error here
startStop.perform();
visit XYZ.com need to click. The entire TextView id is “new_order”
To place a new order, visit XYZ.com.
Screenshot:
removed first answer.
update code to something like:
MobileElement el = (MobileElement) driver.findElementById("new_order");
Point center = el.getCenter();
TouchAction startStop = new TouchAction(driver)
.tap(point(center.x + (el.getSize().width / 2) - 5, center.y)); // where -5 is to avoid el right border
startStop.perform();
check that “el” will be found
@Aleksei Thanks it’s working on pixel 2 device1. i hope it will work on all device sizes.
And also two more question . 1.How did you calculate that it should be -5?
2. How to make it work when we have more than one clickable link like one mentioned by Prashanth
What if the clickable text is dynamic(sometimes first line and sometimes second line) and in the middle of string…How can we make it work?
Like, say Example: “place a new order, with XYZ.”
Hi Aleksei,
I tried the way but tap is not being performed. I have used Google_Pixel_real device
MobileElement el = (MobileElement) driver.findElement(By.xpath("//*[contains(@text,‘Details’)]"));
Point center = el.getCenter();
TouchAction startStop = new TouchAction(driver)
.tap(point(center.x + (el.getSize().width / 2) - 5, center.y)); // where -5 is to avoid el right border
startStop.perform();
can you please let me know are we able to click as clickable is false but enabled is true.
If so, Please let me know what to change here for x and y coordinates.
MobileElement el = (MobileElement) driver.findElement(By.xpath("//*[contains(@text,‘Details’)]"));
for (int step = 5; step <= el.getSize().width; step = step + 5) {
System.out.println("step: '" + step + "'");
PointOption pointOption = new PointOption()
.withCoordinates(el.getLocation().x + step, el.getLocation().y - 10); // you can change '10' do any value that better fit
new TouchAction(driver).tap(pointOption).perform();
try {
Thread.sleep(5000); // 5 sec wait to see if tap happened and 'Details' link pressed
} catch (Exception ignored) {
}
}