尝试点击My Naukri悬停菜单中的管理配置文件选项时,无法找到该元素并获取org.openqa.selenium.ElementNotInteractableException: Element <a href="https://my.naukri.com/ManageProfiles/view"> could not be scrolled into view
例外
for(String ManageProfileWindow : naukriProfileCreation.getWindowHandles())
{
naukriProfileCreation.switchTo().window(ManageProfileWindow);
}
Actions hovermenu = new Actions(naukriProfileCreation);
Thread.sleep(4000);
WebElement ManageProfile = naukriProfileCreation.findElement(By.linkText("Manage Profiles"));
Thread.sleep(4000);
((JavascriptExecutor)naukriProfileCreation).executeScript("window.scrollTo(" + ManageProfile.getLocation().x + "," + ManageProfile.getLocation().y + ")");
naukriProfileCreation.findElement(By.cssSelector(".rghtSec > li:nth-child(2) > div:nth-child(2) > ul:nth-child(2) > li:nth-child(3) > a:nth-child(1)")).click();
Thread.sleep(4000);
ManageProfile.click();
HTML:
<li><a href="https://my.naukri.com/ManageProfiles/view" title="Manage Profiles">Manage Profiles</a></li><li><a href="https://resume.naukri.com/subscription" title="My Fastforward Services">My Fastforward Services</a></li><li><a href="https://login.naukri.com/nLogin/Logout.php" title="Logout">Logout</a></li></ul></div>
答案 0 :(得分:0)
您需要将鼠标悬停在Manage Profile
的父菜单上才能显示子显示,然后才能操作任何子菜单。
当从UI中看不到它时,您无法直接操作它。
WebElement parentMenu = driver.findElement(By.xpath("//div[text()='My Naukri']"));
Actions builder = new Actions(driver);
builder.moveToElement(parentMenu).perform();
WebElement subMenu = driver.findElement(By.xpath("//a[text()='Manage Profiles']"));
subMenu.click();