Protractor - does anybody know how to click on element with RIGHT MOUSE BUTTON?

13,240

Solution 1

I would have done like this:

browser.actions().mouseMove(el.find()).perform();
browser.actions().click(protractor.Button.RIGHT).perform();

Based on what I saw in actionsequence.js and Protractor rightClick issue #280

Solution 2

The accepted solution for this question isn't the best way to go about this. Browser actions' .click() method accepts an optional arg for clicking the right button. A better solution, from the webdriverJs api is:

browser.actions()
    .click($('.myElm'), protractor.Button.RIGHT)
    .perform();
Share:
13,240
Admin
Author by

Admin

Updated on July 29, 2022

Comments

  • Admin
    Admin over 1 year

    I know that protractor click on element by default with left mouse button. How to do it to click with RIGHT MOUSE BUTTON ?

    el.click('RIGHT'); ?

  • glepretre
    glepretre about 10 years
    I think that protractor.Key.RIGHT performs a right arrow keypress, am I wrong?
  • Klas Mellbourn
    Klas Mellbourn about 9 years
    The browser.actions() way seems to have broke in protractor 2.0?
  • glepretre
    glepretre about 9 years
    @KlasMellbourn If there is a breaking change, it should come from Webdriver which has been upgraded in Protractor 2.0. Have you seen its changelog? I'll take a look too. You can also open an issue on Protractor GitHub ;)
  • Klas Mellbourn
    Klas Mellbourn about 9 years
    @glepretre I have now raised this issue github.com/angular/protractor/issues/2043
  • hughes
    hughes over 7 years
    I got el.find is not a function. Had to use el.getLocation() instead, but otherwise this worked.
  • Sameera De Silva
    Sameera De Silva over 4 years
    In Protractor 5.4.2 version with Jasmine , below code is no longer working . Could you please suggest something else since it does nothing ? Thank you . browser.actions().mouseMove(el.getLocation()).perform(); browser.actions().click(protractor.Button.RIGHT).perform()‌​;