Right/Context Click in IE11 using selenium webdriver is not working properly

Chandresh Parmar :

I have to perform right click on a element on a page to open/select a context menu. When I try to do this, using Action class it performs the click operation but not on the element. It executes contextClick() command at some other place on screen instead of element I have passed as a argument to contextClick().

I am running application on Windows 10 with IE11.

Here is the HTML code of page.

<ul id="menus" class="list" style="height: 613.734px;">
    <li id="1" class="default">
        <div class="inner-div" style="display: inline;">
            <span class="menu"></span>
            <span class="menu-title">Delete All</span>
        </div>
        <div class="menuBtn" title="Hide"></div>
    </li>
    <li id="2" class="default">
        <div class="inner-div" style="display: inline;">
            <span class="menu"></span>
            <span class="menu-title">Delete User</span>
        </div>
        <div class="menuBtn" title="Hide"></div>
    </li>
    <li id="3" class="default">
        <div class="inner-div" style="display: inline;">
            <span class="menu"></span>
            <span class="menu-title">Add User</span>
        </div>
        <div class="menuBtn" title="Hide"></div>
    </li>
</ul>

This is the code I am trying.

WebElement element = driver.findElement(By.xpath("//li[.='Add User']");
Actions action= new Actions(driver);
action.contextClick(element).perform();

I have tried with below InternetOptions as well but no luck.

InternetExplorerOptions ieCapabilities = new InternetExplorerOptions();
ieCapabilities.setCapability("nativeEvents", true);    
ieCapabilities.setCapability("unexpectedAlertBehaviour", "accept");
ieCapabilities.setCapability("ignoreProtectedModeSettings", true);
ieCapabilities.setCapability("disable-popup-blocking", true);
ieCapabilities.setCapability("enablePersistentHover", false);
new InternetExplorerDriver(ieCapabilities);

It should right click on the element like it does in all the other browsers, however; it performs rightClick on different location instead of the element given.

Can anyone please help me on this?

Chandresh Parmar :

IE Installation issue was there during OS update. Seems to be resolved after reimage.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=156349&siteId=1