C# Selenium WebDriver FindElement(noSuchElementId)抛出TimeoutException而不是NoSuchElementException

C# Selenium WebDriver FindElement(noSuchElementId)抛出TimeoutException而不是NoSuchElementException,c#,selenium,webdriver,C#,Selenium,Webdriver,在IE 11和Selenium 2.37尝试获取具有无效elementId的元素文本时: TimeSpan pageLoadTimeout = new TimeSpan(HOURS, MINUTES, m_WebPageSettings.PageLoadTimeoutSeconds); InternetExplorerOptions IeOptions = new InternetExplorerOptions() { InitialBrowserUrl = m_WebPageUrl,

在IE 11和Selenium 2.37尝试获取具有无效elementId的元素文本时:

TimeSpan pageLoadTimeout = new TimeSpan(HOURS, MINUTES, m_WebPageSettings.PageLoadTimeoutSeconds);

InternetExplorerOptions IeOptions = new InternetExplorerOptions()
{
    InitialBrowserUrl = m_WebPageUrl,
    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
    BrowserAttachTimeout = pageLoadTimeout,
    RequireWindowFocus = true,
    IgnoreZoomLevel = true
};

m_Driver = new InternetExplorerDriver(AppDomain.CurrentDomain.BaseDirectory, IeOptions);

m_Driver.Manage().Timeouts().SetPageLoadTimeout(pageLoadTimeout);
m_Driver.Manage().Timeouts().SetScriptTimeout(pageLoadTimeout);            
m_Driver.Manage().Timeouts().ImplicitlyWait(pageLoadTimeout);

result = m_Driver.FindElement(By.Id(elementId)).Text;
引发此异常:

OpenQA.Selenium.WebDriverException was caught
  HResult=-2146233088
  Message=The HTTP request to the remote WebDriver server for URL http://localhost:56732/session/4d8e064a-90b7-45f2-a7bc-42c7845534a4/element timed out after 60 seconds.
  Source=WebDriver
  InnerException: System.Net.WebException
       HResult=-2146233079
       Message=The operation has timed out
       Source=System
       StackTrace:
            at System.Net.HttpWebRequest.GetResponse()
            at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
堆栈跟踪:

 at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request) 
       at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) 
       at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value) 
       at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(String id) in 
       at OpenQA.Selenium.By.<>c__DisplayClass2.<Id>b__0(ISearchContext context) 
       at OpenQA.Selenium.By.FindElement(ISearchContext context) 
       at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by) 
       at Alpha.Dsm.WebPage.Utilities.WebPageInteractor.GetTableCellString(String cellId) 

为什么它不抛出OpenQA.Selenium.NoSuchElementException以及如何将其设置为?

尝试跨安全区域设置为相同,并设置
IntroductionInstabilityByIgnoringProtectedModeSettings=false
。另外,你的代码在早期版本的IE中是否有效?这个特定的错误在过去已经被讨论了很多:……似乎有很多因素会导致它,但首先,一定要按照@Faiz所说的去做。另外,你的
pageLoadTimeout
是否用于
超时()
,大于60秒,这是默认的webdriver超时?如果是这样的话,我想webdriver会像现在一样在其他人之前超时。谢谢你的帮助。我将IntroductionInstabilityBygnoringProtectedModeSettings设置为false,现在正在测试。将超时更改为小于60秒修复了IE的问题。感谢您的洞察力!