WinAppDriver found the element but could not click because of the "the referenced element is no longer attached to the DOM." exception

When I tried to click on a hyperlink element, it throws the "An element command failed because the referenced element is no longer attached to the DOM." exception, even though the element is displayed on the window that driver is focusing on.

The element is showing in Accessibility Inside as image below:

enter image description here

Here is my code:

var element = driver.FindElementByName("event#LinkId=1");
element.Click();

The exception was thrown at line 2. The same exception was thrown when I tried to use MoveToElement() or element.Location.X.

But it works well if clicking on the parent element:

driver.FindElementByAccessibilityId("linkText").Click();

Another issue, the driver could not find the element if using:

driver.FindElementByXPath("//Document[@AutomationId=\"linkText\"]/Hyperlink[contains(@Name, 'event')]");

Below is some properties of the hyperlink element:

ControlType = Hyperlink(50005)
IsEnabled = True
IsOffscreen = False
IsKeyboardFocusable = False
HasKeyboardFocus = False

Does anyone knows how to fix this issue?



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)