开发者

always clicks first menu item after hover

开发者 https://www.devze.com 2023-04-11 20:29 出处:网络
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 c

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号