【发布时间】:2017-01-10 20:52:39
【问题描述】:
我的代码应该点击下拉菜单中的值,我有这个代码:
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();
我试图重写你的代码,我用 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();
我的错误是:
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
谁能帮我写字。我是初学者。
【问题讨论】:
标签: selenium drop-down-menu mouseover pageobjects