将鼠标悬停在菜单上,然后点击带有selenium的子菜单c# [英] Hover on menu and click on submenu with selenium c#

查看:118
本文介绍了将鼠标悬停在菜单上,然后点击带有selenium的子菜单c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我正在用c#编写脚本,



我写了代码对于菜单悬停和子菜单单击如下所示,



操作操作=新操作(驱动程序);

IWebElement menuHoverLink = driver.FindElement (id,idofelement);



actions.MoveToElement(menuHoverLink).Build()。Perform();



通过submenucss = By.CssSelector(cssselectorofelement);



WebDriverWait wait1 = new WebDriverWait(driver,TimeSpan.FromSeconds(20)) ;

wait1.Until(ExpectedConditions.ElementExists(submenucss));

IWebElement子菜单= driver.FindElement(submenucss);

子菜单。点击();



但它并不适用于所有浏览器。



我希望代码有效全部或至少(chrome,firefox,IE)。



if anyb然后请分享你的知识。



问候,

Kedar Borkar。

解决方案

Hello All,

I am writing scripts in c#,

I have written the code for menu hover and sub menu click just as below,

Actions actions = new Actions(driver);
IWebElement menuHoverLink = driver.FindElement("id", "idofelement");

actions.MoveToElement(menuHoverLink).Build().Perform();

By submenucss = By.CssSelector("cssselectorofelement");

WebDriverWait wait1 = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
wait1.Until(ExpectedConditions.ElementExists(submenucss));
IWebElement submenu = driver.FindElement(submenucss);
submenu.Click();

But it is not working for all browsers.

I want the code that works in all or atleast (chrome,firefox,IE).

If anybody have the idea then please share your knowledge.

Regards,
Kedar Borkar.

解决方案

这篇关于将鼠标悬停在菜单上,然后点击带有selenium的子菜单c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆