Protractor: Right click is not performed on Chrome v75. Instead a left click action is performed.

Created on 2 Jul 2019  路  5Comments  路  Source: angular/protractor

Bug report

I have some tests trying to simulate a right click as follows:

  browser.actions().mouseMove($('#id')).perform();
  browser.actions().click(protractor.Button.RIGHT).perform();

It worked fine on following configuration:

Chrome V74
ChromeDriver V74
selenium-server-standalone-3.141.59.jar
"@types/node": "^12.0.10",
"jasmine": "^3.4.0",
"protractor": "^5.4.2",
"typescript": "^3.5.2",
"webdriver-manager": "^12.1.5"

After updating Chrome and ChromeDriver to V75 right click is no longer performed. A left click is performed instead.

I found following workaround: If I set 'directConnect' property to true the right click is performed.
Using directConnect is not an option since we also want to run tests on IE.

  • Node Version: 12.0.10
  • Protractor Version: 5.4.2
  • Browser(s): Chrome 75
  • Operating System and Version Windows 10
  • Protractor configuration file
exports.config = {
    // launch locally when fields directConnect and seleniumAddress are not provided
    //directConnect: true,
    chromeDriver: 'C:\\source\\protractorProj\\drivers\\chromedriver.exe',
    seleniumServerJar: 'C:\\source\\protractorProj\\drivers\\selenium-server-standalone-3.141.59.jar',
    specs: ['C:\\source\\protractorProj\\specs\\tests.js'],
    capabilities: {
      browserName: 'chrome'
    }
  }
  • A relevant example test
   import {browser, $, protractor} from 'protractor'

  describe('Protractor Typescript Demo', function() {
    it('title verifications', function() {
      browser.get('https://talis.github.io/ng-context-menu/#/');
      browser.sleep(3000);browser.actions().mouseMove($('#panel-0 .panel-body')).perform();
          browser.actions().click(protractor.Button.RIGHT).perform();
          browser.sleep(5000);

          browser.actions().mouseMove($('a')).perform();
          browser.actions().click(protractor.Button.RIGHT).perform();
          browser.sleep(2000);
    });
});

I run the test with following command: "protractor conf.js"

Request

I would expect that the right click is performed as in previous versions.

I also did a test in Java using Selenium and the right click was done correctly both on Chrome 74 and 75 by using these lines of code
WebElement elementLocator = driver.findElement(By.id("ID"));
actions.contextClick(elementLocator).perform();

So I suppose there is something related to the way protractor sends the right click event and the way chromedriver handles it

Most helpful comment

Hi @alexcergau, @raketenolli

enabling the below capability enables chrome 74+ to use legacy API. Please try it works.

'goog:chromeOptions': {
w3c: false
}

Thanks !

All 5 comments

I'm experiencing the same problem with webdriverio, so I'd suspect the problem to be somewhere in Selenium/Chromedriver.

Hi @raketenolli ,@alexcergu,

Chrome 74 uses few legacy API like sendKeysToActiveElement etc and those are now deprecated in chrome 75. To make your tests work with keyboard actions, you may have to try in this way

driver.findElement(By.cssSelector("[name=\"q\"]")).click(Keys.ENTER);

Thanks,

I have the same issue.
It's weird but "directConnect: true," fix this issue. Never the less this is not acceptable for me ((

Hi @alexcergau, @raketenolli

enabling the below capability enables chrome 74+ to use legacy API. Please try it works.

'goog:chromeOptions': {
w3c: false
}

Thanks !

The solution from previous comment works for me. But I think it's just a workaround.
So we need some permanent fix. Like how to do the right click with Protractor, that will work.

Was this page helpful?
0 / 5 - 0 ratings