I keep getting this error, I am need to testing so it maybe my code but I am not sure.
Here is my code:
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\selenium-2.44.0\\chromedriver.exe");
// System.setProperty("webdriver.ie.driver", "C:\\selenium-2.44.0\\IEDriverServer.exe");
WebDriver driver = new ChromeDriver();
// WebDriver driver = new InternetExplorerDriver();
// WebDriver driver = new FirefoxDriver();
driver.get("https://multichannel-custom-qa.Support/");
driver.findElement(By.id("userID")).sendKeys("REH01");
driver.findElement(By.name("j_password")).sendKeys("YE02year");
driver.findElement(By.name("action")).submit();
String tagName = "";
driver.findElement(By.linkText("Workbench")).click();
WebElement searchBox;
searchBox = driver.findElement(By.xpath("//input[@type='text']"));
searchBox.sendKeys("X1508706");
searchBox.findElement(By.cssSelector("css=button.btn.btn-default")).click();
Thread.sleep(5000);
searchBox.findElement(By.cssSelector("css=button.btn.btn-default"));
searchBox.click();
WebElement link;
link = driver.findElement(By.linkText("X1508706"));
link.click();
Thread.sleep(5000);
And here is the error:
Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=39.0.2171.95)
(Driver info: chromedriver=2.12.301325 (962dea43ddd90e7e4224a03fa3c36a421281abb7),platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 214 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00'
System info: host: 'C9090DEF19ED258', ip: '172.22.46.117', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_20'
Session ID: e3c034f27280c888088da4ba7922cdee
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=C:\Users\kxh8178\AppData\Local\Temp\1\scoped_dir8948_22544}, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=39.0.2171.95, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:89)
at driverTest.tests.main(tests.java:33)