我現在正在自動化一個web應用程序。我已經使用了一個列表數組來定位一個容器內的幾個對象。我需要做的是,我必須將鼠標懸停在第一個元素上並單擊相同的按鈕。我在另一個類中寫入的鼠標懸停方法作爲常用函數。因此,我可以使用列表數組的對象以任何方式傳遞給鼠標懸停方法。我們可以將列表<WebElement>的對象作爲參數傳遞給函數嗎?
找到在容器中的元素。
By by = By.xpath("//ul[@id='sortable']");
List<WebElement> featureList= element.findElements(by.tagName("a"));
//Mouse-hover method
public static void moveMouseOver(WebDriver driver, By locator) {
WebElement element = waitForElementPresent(driver, locator);
(new Actions(driver)).moveToElement(element).build().perform();
}
Here can I change the 'By Locator' argument to replace with List array object ?
It限制在'MoveMouseOver方法中插入WebElement webElements,它返回錯誤爲「ExecutionHelper類型中的方法moveMouseOver(WebDriver,By,String)不適用於參數(WebDriver,By,Object [])」 – 2015-03-20 06:48:24
調用方法? – 2015-03-20 06:49:53
ExecutionHelper.moveMouseOver(driver,by,featureList.toArray()); – 2015-03-20 06:54:44