我正在尝试使用以下代码使用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
无法正确加载并引发异常。有人可以告诉我为什么会这样吗?