我试图使用以下代码使用Selenium打开最后下载的项目;
  
                  IJavaScriptExecutor executor = (IJavaScriptExecutor)WebDriver;
                executor.ExecuteScript("window.open();");
                WebDriver.SwitchTo().Window(WebDriver.WindowHandles[1]);
                WebDriver.Navigate().GoToUrl("chrome://downloads");
                WebDriver.SwitchTo().Window(WebDriver.WindowHandles.Last());
                //Open up the attachment, close the downloads page, switch driver focus to attachment page,
                //gets the text from the attachment page, closes attachment page,
                try
                {
                    IWebElement manager = WebDriver.FindElement(By.CssSelector("body/deep/downloads-manager"));
                    IWebElement item = manager.FindElement(By.CssSelector("body/deep/downloads-item"));
                    IWebElement shadow = (IWebElement)executor.ExecuteScript("return arguments[0].shadowRoot;", item);
                    IWebElement link = shadow.FindElement(By.CssSelector("div#title-area>a"));
                    link.Click();
  
   我切换到了正确的帧,但是
   
    item
   
   未正确加载并引发异常。有人能告诉我为什么会这样吗?