我想用selenium webdriver點擊子菜單項,這是默認不可見的。 它在mousehover上可見。 我試着用一些代碼,如下圖所示用webdriver selenium處理子菜單項
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is not currently visible and so may not be interacted with.
下面的代碼是給錯誤:
Actions actions = new Actions(driver);
WebElement menuHoverLink = driver.findElement(By.linkText("RENT"));
//WebElement menuHoverLink = driver.findElement(By.className("current"));
actions.moveToElement(menuHoverLink);
WebElement subLink = driver.findElement(By.cssSelector("a[href='nemc.com/rentals/easy-rent']"));
actions.moveToElement(subLink);
actions.click();
actions.perform();
您的鼠標懸停邏輯有問題改變它。請向我們展示您的代碼? – Hemanth 2013-04-23 04:48:52
我已經使用了下面的代碼,它正在工作,但問題是它重定向到其他菜單項:操作actions = new Actions(driver); \t WebElement menuHoverLink = driver.findElement(By.linkText(「RENT」)); \t // WebElement menuHoverLink = driver.findElement(By.className(「current」)); \t actions.moveToElement(menuHoverLink); \t \t WebElement subLink = driver.findElement(By.cssSelector(「a [href ='http://www.nemc.com/rentals/easy-rent']」)); \t actions.moveToElement(子鏈路); \t actions.click(); \t actions.perform(); – 2013-04-23 06:38:30
編輯我的答案..如果出來..如果它的網站你可以分享..然後分享網址.. – 2013-04-23 07:32:50