【发布时间】:2014-04-16 09:25:09
【问题描述】:
当我注销并尝试登录同一页面时,“缓存中未找到元素 - 页面可能在查找后已更改”。
在上述情况下,登录应用程序成功,当我从应用程序注销时,再次显示登录页面。问题是:当我尝试在同一页面中再次登录时,它显示 Element not found in cache - 也许页面在查找后已更改
登录网址(新鲜,第一次)://firco/en_US/ d Logput URL(再次显示登录页面)://firco/en_US/logout/
我想在第一次和第二次登录时使用相同的驱动程序(浏览器实例)。
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.sendKeys("SUGU");
在上面的代码中,我想在第一次和第二次登录时(注销后)在同一个驱动程序中使用 uname
【问题讨论】:
-
这是因为退出后页面刷新了。您需要在登录元素上再次
findElement。 -
请分享您的代码
-
Anand S ...我已添加我的代码供您参考..
标签: java selenium selenium-webdriver element browser-cache