How to avoid MouseOver on Selenium Click()

前端 未结 2 1378
囚心锁ツ
囚心锁ツ 2020-12-22 14:01

In one of my Selenium test cases, I have the problem that there are MouseOver effects that I don\'t want to have. This is what I do:

  1. Click on the \"login\" but
2条回答
  •  礼貌的吻别
    2020-12-22 14:22

    I still don't know the real solution, but here's the dirty workaround I'm using:

    public static void Click(this IWebElement element, TestTarget target)
    {
        if (target.IsInternetExplorer)
        {
            var actions = new Actions(target.Driver);
            actions.MoveToElement(element).Perform();
            Thread.Sleep(500); // wait for the mouseover popup to appear
            element.SendKeys(Keys.Escape); // to close the popup (if any)
            actions.MoveToElement(element).DoubleClick().Perform(); // simple click is sometimes not enough in IE
        }
        else
        {
            element.Click();
        }
    }
    

提交回复
热议问题