我对硒有一些问题。
我想String content
用 id="source" 向我的网络上的一个元素发送一些内容,并在此处提交是我的代码
driver.get("http://hiriji.com/");
WebElement viet = driver.findElement(By.id("source"));
viet.sendKeys(content);
viet.submit();
它运作良好,直到内容太大。
后
viet.sendKeys(content);
网页突然变成 404 错误页面。所以它在
viet.submit();
我的问题是如何忽略这个错误并继续下面的代码。我不需要将所有内容都发送到网络上,如果它太大可以忽略...
堆栈跟踪说:
Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up
Command duration or timeout: 392 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_31'
Driver info: driver.version: RemoteWebDriver
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:244)
at org.openqa.selenium.remote.RemoteWebElement.submit(RemoteWebElement.java:81)
at RecieveData.TranslateStatus.translateViToEn(TranslateStatus.java:22)
at RecieveData.htmlParser.parseHtml(htmlParser.java:43)
at RecieveData.AddressToHtml.parseHtmlStatus(AddressToHtml.java:105)
at RecieveData.MainProcess.main(MainProcess.java:29)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element not found in the cache - perhaps the page has changed since it was looked up
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_31'
Driver info: driver.version: unknown