I am trying to click on an element using LinkText. Eg:
myelement = driver.FindElement(By.LinkText(StoreFile)) 'Click on report by name
logger.Debug("Report Found as " & myelement.Text)
If myelement Is Nothing Then
GoTo endTry
Else
myelement.Click()
logger.Debug("Report clicked is " & StoreFile)
End If
But, I get the following error:
The Error Is OpenQA.Selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=66.0.3359.139)
(Driver info: chromedriver=2.35.528161
(5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebElement.Click()
at ExcelAddIn1.Ribbon1.BrandReview(String ReadFile).
Is there a reason as to why it can't find the element using the LinkText even though the element is visible on the web page? Is there a solution to resolve this, please help?