我正在尝试使用 LinkText 单击一个元素。例如:
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
但是,我收到以下错误:
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).
即使元素在网页上可见,为什么它无法使用LinkText找到元素是否有原因?有没有办法解决这个问题,请帮忙?