Selenium 2.0b3 IE WebDriver, Click not firing

后端 未结 18 1957
我寻月下人不归
我寻月下人不归 2020-11-29 02:33

When using the IE driver with IE9, occasionally the Click method will only select a button, it wont do the action of the Click(). Note this only happens occasionally, so i d

18条回答
  •  误落风尘
    2020-11-29 03:03

    A better way to force the focus on the element is to use Javascript. This works when your elements are tagged with id attribute. If they're not, get the developers to change it.

    Find the element using whatever locator/properties you need. Once the element is retrieved, check to see if it contains an ID attribute. If it does, then execute the following code which will force focus to the element:

    JavascriptExecutor executor = (JavascriptExecutor) webDriver();
    executor.executeScript("document.getElementById('" + element.GetAttribute("id") + "').focus()");
    

    Using this, almost all the issues with missed clicks were resolved when using the InternetExplorerDriver.

提交回复
热议问题