在使用c#的selenium webdriver中,如何通过单击按钮来测试菜单折叠和展开

时间:2016-10-11 00:40:51

标签: c# selenium selenium-webdriver

Selenium C#中,我试图编写一个代码,用于在我click菜单按钮时进行测试,下方菜单会折叠并展开。

任何提示都会有所帮助。感谢。

1 个答案:

答案 0 :(得分:0)

  

我试图编写一个代码,当我单击菜单按钮时测试,下面的菜单折叠并展开

如果要在点击菜单按钮后验证特定元素是展开还是折叠,只需检查该目标元素的IWebElement#Displayed属性。

//Click on menu button element 

//Now find desire node to verify its expanded or collapsed 
IWebElement element = driver.FindElement(..);
if(element.Displayed)
{
  Console.WriteLine("Expanded");
}else
{
  Console.WriteLine("Collapsed");
}