RE: Advise on locating elements when there is a page refresh that happens

Hi ,

Am trying to automate JIRA application create_issue .When create button is clicked , there is page which gets displayed that allows us to select project,issue_type, summary etc and then finally submit .

I observe that when we select a project in the project field and press enter, the page gets refreshed . Now i try to locate the next element which is issue_type but get the below error.

Clicked on create_link
Project Selected
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: 10.05 seconds

Could you please help identify what could be the issue ?

Thanks

Below is the JAVA code
————————-

driver.findElement(By.xpath(“.//*[@id=’create_link’]”)).click();
System.out.println(“Clicked on create_link”);
WebElement project = driver.findElement(By.xpath(“.//*[@id=’project-field’]”));
project.click();
project.sendKeys(Keys.BACK_SPACE);
project.sendKeys(“A Test Project”);
project.sendKeys(Keys.ARROW_DOWN);
project.sendKeys(Keys.ENTER);
System.out.println(“Project Selected”);

wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(“//div[@id=’issuetype-single-select’]”)));
WebElement issue = driver.findElement(By.xpath(“.//input[@id=’issuetype-field’]”));

Asha Default Asked on November 21, 2014 in Selenium WebDriver.
Add Comment
3 Answers

Thanks Ankit . Will try to catch the StaleElementReferenceException exception and retry to  findElement .

Default Answered on November 21, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.