Not able to perform the click operation

Appium version 1.6.5

java client 5.0.3

FAILED: f
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: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘3.5.3’, revision: ‘a88d25fe6b’, time: ‘2017-08-29T12:54:15.039Z’
System info: host: ‘USER-PC’, ip: ‘192.168.1.18’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_144’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.raaga.android, deviceScreenSize=1080x1920, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=7f2ef0fe, platform=LINUX, deviceUDID=7f2ef0fe, appActivity=com.raaga.android.SplashScreen, desired={appPackage=com.raaga.android, appActivity=com.raaga.android.SplashScreen, newCommandTimeout=25, platformName=Android, deviceName=Android device}, newCommandTimeout=25, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, javascriptEnabled=true, deviceModel=Redmi Note 3, deviceManufacturer=Xiaomi, platformName=LINUX}]
Session ID: 1a5e724a-2fbd-4589-9ecf-6f364a23a1dd
*** Element info: {Using=-android uiautomator, value=new UiScrollable(new UiSelector()).scrollIntoView(text(“World Music”));}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.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:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:82)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
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:416)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.FindsByAndroidUIAutomator.findElementByAndroidUIAutomator(FindsByAndroidUIAutomator.java:32)
at com.appium.check.Appium.f(Appium.java:38)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0

===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0

here exacatly it’s finding the element and not clicking on that, because of that it’s not able to locate the other element i.e the world music…

here is my code

package com.appium.check;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

import com.appium.common.InvokeRaaga;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;

public class Appium {
AndroidDriver driver;
@Test
public void f() throws MalformedURLException, InterruptedException {
driver=InvokeRaaga.runAppium();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
/wait for the element to skip/
while(true){
try{
AndroidElement skip= driver.findElementByXPath("//android.widget.TextView[@text=‘SKIP’]");
if(skip.isDisplayed()){
skip.click();
break;
}

	  }
	  catch(Throwable t){
		  Thread.sleep(500);
	  }
  }
  /*scroll to worldmusic*/
  driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"World Music\"));");
  driver.findElementByXPath("//android.widget.TextView[@text='World Music']").click();
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  driver.findElementByXPath("//android.widget.Button[@text='Ok, Got it']").click();
  /*scroll to raaga live*/
  driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"com.raaga.android:id/music_home_raaga_live\"));");
  driver.findElementById("com.raaga.android:id/music_home_raaga_live").click();

}
}

this is NOT correct. update to something like:

String text = "your text"
WebElement el = driver.findElement(MobileBy
                    .AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("
                            + "new UiSelector().text(\""+text+"\"));")));

Thanks Aleksei for your reply. it was working fine with the scrolling code what i have written but it was not able to click on the element, But some how it worked after some time…:grinning::grinning:

this is the scrolling code what i have implemented in my framework.

/*
* This function is to scroll to particular element
* here is the real
* driver.findElementByAndroidUIAutomator(“new UiScrollable(new UiSelector()).scrollIntoView(text(“Animation”));”);
* */

public static void scrollToElemntBytext(AndroidDriver<AndroidElement> driver,String text){
	String s1="new UiScrollable(new UiSelector()).scrollIntoView(text(\"";
	String s2="\"));";
	driver.findElementByAndroidUIAutomator(s1+text+s2);
}

public static void scrollToElemntByid(AndroidDriver<AndroidElement> driver,String id){
	String s1="new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"";
	String s2="\"));";
	driver.findElementByAndroidUIAutomator(s1+id+s2);
}

@suryakanta939 dont use click try tap instead. with your code it should be like:

        // scroll to element
        WebElement el = driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"com.raaga.android:id/music_home_raaga_live\"));");
        // tap element
        new TouchAction(driver).press(el).waitAction(Duration.ofMillis(70)).release().perform();

Thanks, It’s working fine now, If you could provide the sample code of how to scroll up in the latest version of appium1.6.5 as the driver.swipe() function is not available ,Then it will be great…Thanks Again:smile::smiley:

@suryakanta939 choose something from - Swipe/Scroll best practice with Java-Client 5 and below