Selenium

Aus Peter Jauernig Wiki
Version vom 31. März 2015, 10:55 Uhr von Pj-wiki (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „ Code: public static void moveBeginMonthForward (int times) throws Exception{ System.out.println(times); //Select Month // We…“)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche


Code:

public static void moveBeginMonthForward (int times) throws Exception{


System.out.println(times); //Select Month // WebElement fw = driver.findElement(By.xpath(urlaub_month_sel_from_fw_xpath)); WebElement fw = driver.findElement(By.linkText("Next"));

for(int i=0; i<times; i++) { System.out.println("Clicking foward beginning ..."); fw.click(); System.out.println("Clicked foward beginning ..."); Thread.sleep(1000); } }

Error: org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM

A StaleElementException is thrown when the element you were interacting is destroyed and then recreated. Most complex web pages these days will move things about on the fly as the user interacts with it and this requires elements in the DOM to be destroyed and recreated.