"Element not found in the cache - perhaps the page has changed since it was looked up" displayed "Element not found in the cache - perhaps the page has changed since it was looked up" displayed selenium selenium

"Element not found in the cache - perhaps the page has changed since it was looked up" displayed


Web elements you stored before clicking on login button will not be present in cache after login because of page refresh or page changes. You need to again store these web elements in order to make them available again under cache. I have modified your code a bit which might help:

public static void main(String[] args) WebDriver driver = new FirefoxDriver();driver.get("//Continuity/en_US/");driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);WebElement uname = driver.findElement(By.xpath(".//*[@id='text-input-element-15']"));WebElement pwd = driver.findElement(By.xpath("id('text-input-element-16')"));WebElement busunit = driver.findElement(By.xpath("id('text-input-element-22')"));WebElement login = driver.findElement(By.id("login-button"));uname.sendKeys("RAGHU");pwd.sendKeys("Hello00");login.click();WebElement LogoutButton = driver.findElement(By.xpath(".//*[@id='logout-button']"));LogoutButton.click();driver.get("//Continuity/en_US/");uname = driver.findElement(By.xpath(".//*[@id='text-input-element-15']"));uname.sendKeys("SUGU");