Click at point without element ID

I was trying to click on the Arrow button can any one help me how to access the feald with the property NFA as true

I have tried with all this
driver.findElementsByClassName(“android.widget.Spinner”).get(2).click();

TouchAction action= new TouchAction(driver);
action.press(972, 109);

TouchAction action= new TouchAction(driver);
action.press(1065, 202);

driver.tap(1, 1065, 202, 1);

but it didn’t work

Can any one help me with a perfect way to come up with this?

@Vaamsi

Can you try click again with the xpath locator?

Try touch action again by including perform().
TouchAction action= new TouchAction(driver);
action.press(x, y).perform();

Also Can you print all the elements with Coordinates for className (“adnroid.widget.Spinner”) ?

1 Like

@harshitj

I tried touch action again with perform but it didn’t work

TouchAction action= new TouchAction(driver);
action.press(1065, 202).perform();

TouchAction action= new TouchAction(driver);
action.press(972, 109).perform();

I tried both the methods but it didn’t work
its giving a error as

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.48 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘2.53.0’, revision: ‘35ae25b’, time: ‘2016-03-15 16:57:40’
System info: host: ‘D-113091089’, ip: ‘10.156.114.75’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_111’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.syclo.agentry.client.sawater, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=4d0076284f2f5125, platform=LINUX, appActivity=com.syclo.agentry.client.android.ui.builtin.StartupActivity, desired={appPackage=com.syclo.agentry.client.sawater, appActivity=com.syclo.agentry.client.android.ui.builtin.StartupActivity, newCommandTimeout=1000, platformVersion=6.0.1, udid=4d0076284f2f5125, platformName=Android, device=Android, deviceName=Galaxy S5}, newCommandTimeout=1000, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, udid=4d0076284f2f5125, platformName=Android, device=Android}]
Session ID: 19574360-f9b4-4904-b2ad-92c24c3c6311
*** Element info: {Using=id, value=com.syclo.agentry.client.sawater:id/text}
at sun.reflect.GeneratedConstructorAccessor8.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:56)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:413)
at io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:64)
at io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementById(AndroidDriver.java:1)
at com.test.WoApp.testUntitled(WoApp.java:155)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

And i am getting the X and Y coordinates from Node Details section of UI Automator Viewer as Bounds details

Do we have any function to find the coordinates for all the elements of a class or so.

is the above process which i am using is wrong.

As per the logs no such element exception appeared for the below element.

Use this function and print the coordinate for the elements by the ClassName(“android.widget.Spinner”)

public void getCoordinateByClassName(String cName){
List elements=driver.findElements(By.className(cName));
System.out.println(“No of elements”+elements.size());
for(int i=0;i<elements.size();i++){
System.out.println(“Element-”+i+" coordinates :"+elements.get(i).getLocation());
}
}

1 Like

Try with this:
TouchAction action= new TouchAction(driver);
action.press(271, 642).release().perform();