While automating a mobile test with Appium in C#, I can successfully click the first element 'Nieuw' using XPath.
However, when I try to locate and click another element with the accessibility id 'Proefrit', Appium throws a NoSuchElementException.
Here’s the relevant code:
IWebElement nieuw = (IWebElement)driver.FindElementByXPath("(//android.view.View[@content-desc='Nieuw'])[2]");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementToBeClickable(nieuw));
nieuw.Click();
IWebElement proefrit = (IWebElement)driver.FindElementByAccessibilityId("Proefrit");
wait.Until(ExpectedConditions.ElementToBeClickable(proefrit));
proefrit.Click();
Appium Desktop can locate the element successfully, but the test code fails to find it.
I suspect the element might not be in focus or visible when the test tries to interact with it, possibly due to being inside another frame or view.
How can I ensure the element is properly located and interacted with when using FindElementByAccessibilityId?