An element could not be located on the page using the given search parameters

Hi guys,

I am trying to use TestNG to automate an app on Android device, for instance the Calculator. I used findElement(By.id()), but I got the error: 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)

My code is following:

public class NewTest {
public static AppiumDriver driver;
public static String device=“Android”;
public static String deviceName=“1b2b80b5”;
public static String platformVersion=“7.1.1”;
public static String platformName=“Android”;
@Test
public void setup() throws InterruptedException {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(“device”, device);
cap.setCapability(“deviceName”, deviceName);
cap.setCapability(“platformVersion”, platformVersion);
cap.setCapability(“platformName”, platformName);
cap.setCapability(“appPackage”, “com.android.calculator2”);
cap.setCapability(“appActivity”, “com.android.calculator2.Calculator”);
try {
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), cap);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.id(“com.google.android.calculator:id/digit_1”)).click();
}
catch(MalformedURLException e) {
e.printStackTrace();
}
}
}

Hey. All good?

Did you manage to solve this problem? I’m going through something similar, if not the same thing.

@Alexis_ZH Can you please share the appium log here?