我正在獲取元素沒有附加到上面代碼的頁面文檔錯誤。此外,我想知道如何處理作爲目標頁面上的操作結果的「出現」的元素。線程「main」中的異常org.openqa.selenium.StaleElementReferenceException:陳舊的元素引用:元素未附加到頁面文檔
WebDriver driver = new ChromeDriver();
driver.get("https://www.irctc.co.in/eticketing/loginHome.jsf");
driver.manage().window().maximize();
driver.findElement(By.linkText("Sign up")).click();
//Verify whether the navigation is to the correct page
String title=driver.getTitle();
if (title.equals("IRCTC Next Generation eTicketing System")){
driver.findElement(By.id("userRegistrationForm:userName")).sendKeys("abcdef");
driver.findElement(By.linkText("Check Availability")).click();
WebElement text=driver.findElement(By.xpath(".//*[@id='userRegistrationForm:useravail']"));
boolean availability=text.isDisplayed();
try {if(availability==true){
System.out.println("The user id is available. Please enter other details to complete registration");
}}
catch (NoSuchElementException e){
System.out.println("The user id is not available. Please enter a different user ID.");
}
}
else
System.out.println("You are on a wrong page");
}
}