I am trying to tap on a dynamically generated element in a hybrid application.
I can see the element and select it using the chrome device inspector.
I can select the element by a css selector in my unit test.
I can’t use the returned element to execute a tap action as it throws an exception saying the items is stale/expired.
I am not updating or changing the page in between selecting and using the returned element.
Here is the code snippet that fails, it reports: ```
OpenQA.Selenium.NoSuchElementException: ‘The element identified by ‘0f71bc97-5d49-44d5-b77c-ecbc3691d933’ is not present in the cache or has expired. Try to find it again’
new TouchAction((IPerformsTouchActions)_driver)
.Tap(_driver.FindElement(By.XPath("//div[@id=‘option-14’]")))
.Wait(250)
.Perform();
I have tried this and it works
_driver.FindElement(By.XPath("//div[@id=‘option-14’]")).Click();
I have also tried this and it fails with the same error as above.
var element = _driver.FindElement(By.XPath("//div[@id=‘option-14’]"));
element.Click(); //Throws the same exception as above