always clicks first menu item after hover
I have a menu that is only visible after a mouse hover. The mouse hover works and the menu becomes visible for a moment. An attempted click action always clicks the first item in the menu. I want to command it to click any item in the list. I am currently using the id to find.
IWebElement settingsMenu = _driver.FindElement(By.Id("ctl00_ctl00_Main_Header_SettingsMenu"));
var actionbuilder = new Actions(_driver);
actionbuilder.MoveToElement(settingsMenu);
actionbuilder.Perform(); //perform menu hover, this always works
//menu items now visible
IWebElement ScheduleSettings = _driver.FindElement(By.Id("ctl00_ctl00_Main_Header_lnkSchedulingSettings"));
actionbuilder.MoveToElement(ScheduleSettings);
acti开发者_Python百科onbuilder.Perform();
ScheduleSettings.Click();
The ScheduleSettings is the second item in the menu from top to bottom. The first item always gets clicked.
use this when you are building your driver
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("enablePersistentHover", false);
driver = new InternetExplorerDriver(capabilities);
精彩评论