首页 > 解决方案 > 如何解决此错误 stale element reference: element is not attach to the page document

问题描述

请查找附件代码:

 IWebElement webElement = this.wait.Until<IWebElement>(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("search-for-deals-results")));
    if (webElement != null)
    {
      ReadOnlyCollection<IWebElement> elements = webElement.FindElements(By.XPath("tbody//tr//a[contains(@href,'public/dealList')]"));
      this.issuerList = new List<FileData>();
     
      foreach (var data in elements.Select(l => new
      {
        link = l.GetAttribute("href"),
        name = l.Text
      }))
        this.issuerList.Add(new FileData()
        {
          Name = data.name, 
          Url = data.link 

        });
      this.dealsList = new List<FileData>();
      if (!string.IsNullOrEmpty(issueName))
        this.issuerList = this.issuerList.Where<FileData>((Func<FileData, bool>) (s => s.Name.Contains(issueName))).ToList<FileData>();
      Console.WriteLine("Download Process Started: " + DateTime.Now.ToShortTimeString());
      this.ProcessIssures(this.issuerList, false);
      Console.WriteLine("fdfs" + this.dealsList.Count.ToString());
      this.ProcessIssures(this.dealsList, true);
    }
  }
  Download.driver.Quit();

标签: c#.netentity-frameworklinqselenium-chromedriver

解决方案


推荐阅读