Mein Code auf dem Wert aus dem Dropdown-Menü klicken soll, habe ich diesen Code:Wie schreibt man Mouseover mit PageFactory
WebElement element = driver.findElement(By.xpath("//a[text()='Product Category']"));
Actions action = new Actions(driver);
action.moveToElement(element).perform();
waitForElementToBeDisplayed(driver.findElement(By.xpath("//a[text()='iMacs']")), 500);
WebElement subElement = driver.findElement(By.xpath("//a[text()='iMacs']"));
action.moveToElement(subElement);
action.click();
action.perform();
Ich habe versucht, den Code neu zu schreiben, und ich schreibe mit PageFactory:
WebElement element = mouse_over_product_category;
Actions action = new Actions(driver);
action.moveToElement(element).perform();
waitForElementToBeDisplayed(driver.findElement(By.xpath("//a[text()='iMacs']")), 500);
WebElement subElement = link_iMacs;
action.moveToElement(subElement);
action.click();
action.perform();
Mein Fehler ist:
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
Kann mir jemand helfen, wie man schreibt. Ich bin ein Anfänger.
Gibt dies an me: Kann das Symbol 'GlobalVars' nicht auflösen –
Das war nur meine lokale Instanz von WebDriver. Benutze das aktualisierte. Sollte arbeiten. –
Ihr Code funktioniert, aber öffnet das erste Element im Dropdown-Menü, und ich möchte auf ein anderes klicken. –