开发者

Selenium 2 RemoteWebDriver -StaleElementReferenceException: Element specified by 'id' is no longer valid

开发者 https://www.devze.com 2023-03-28 14:41 出处:网络
I\'m using the 2.4.0 selenium server in hub mode with two nodes each with 5 instances of Internet explorer (IE8 on win7) - this is all running on the same Win7 machine

I'm using the 2.4.0 selenium server in hub mode with two nodes each with 5 instances of Internet explorer (IE8 on win7) - this is all running on the same Win7 machine

The following code throws the exception on the final call to FindElements on the RemoteWebDriver

_driver.Navigate().GoToUrl(@"http://devrsql714/webpages/parentview.aspx");
            var wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 40));
            wait.Until(d => d.FindElement(By.ClassName("TitleAlternative")));
            Console.WriteLine(string.Format("Window title: {0}", _driver.Title));
            var element = _driver.FindElementById("txtLessonID");
            element.SendKeys("13814");
            var button = _driver.FindElementById("btnLessonID");
            button.Click();
            wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 40));
            var link = wait.Until(d => d.Title.Contains("01652-06-A"));
            Console.WriteLine(string.Format("Window title: {0}", _driver.Title));
            Assert.IsTrue(_driver.Title.Contains("01652"));
            Console.WriteLine(string.Format("page source: {0}", _driver.PageSource));
            _driver.FindElementsByTagName("DIV");

I can see the browser load, navigate, fillin the text box and click the button - the page refreshes the title changes - the assert passes (this is running in MbUnit with Gallio)

but the subsequent call to _driver.FindElementsByTagName throws the exception below - I added waits in case that was the issue and any find elements results in the same exception

what am I doing wrong? - other properties on the driver work such as title and page source (which has the excepted content)

Note the same code but swapping the RemoteWebDriver for a local InternetExplorerDriver does not throw the exception

In both cases capabilities were set to ignore protect mode:

DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer();
            capabilities.Platform = new Platform(PlatformType.Any);
            capabilities.SetCapability("ignoreProtectedModeSettings"开发者_开发知识库, true);

Execute
OpenQA.Selenium.StaleElementReferenceException: Element specified by 'id' is no longer valid (WARNING: The server did not provide any stacktrace information)
Build info: version: '2.4.0', revision: '13337', time: '2011-08-12 09:57:13'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 948
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 805
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElements(String mechanism, String value) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 851
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementsByTagName(String tagName) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 622
   at SeleniumTests.DemoTest.AnotherTest() 


This is apparently a bug in version 2.4.0 of the selenium server. Downgrading to 2.3.0 might make the problem go away. See this thread on the selenium-users mailing list for more information.

0

精彩评论

暂无评论...
验证码 换一张
取 消