Right Click in Selenium:

 

  • To perform some action, we may need to click on the right click action / references to an element.
  • We use the action class in the Selenium WebDriver to work on mouse and keyboard actions to perform Right Click.
  • Using Action class we create instance / object then call to contextClick Method to perform Right click operation on any WebPage.

 

 

Steps to Handle Right Click in Selenium Using Action Class:

  • Create a Object of Action Class.
  • Perform Right click operation using contextClick Method.
  • Using contextClick Method we call perform().

 

contextClick Method in Action Class:

  • Using contextClick Method we perform Right click operation on WebElement.
  • contextClick Method perform important role in Action class when we want to perform Right Click operation.
  • contextClick Method is time consuming as well as we don’t need to use KeyBoard Events to perform Right Click operation.

 

Right click on WebElement using Action Class contextClick Method:

 

Scenario’s To perform Right Click operation on WebElement using contextClick Method:

  • setProperty of driver to Launch Browser.
  • Create a driver  instance of FirefoxDriver.
  • Create object of Action class to perform Right Click Operation.
  • Find element using locator and store into WebElement.
  • Perform Right click operation using action (object) on element using contextClick method.

 

Example to Perform Right Click operation on WebElement using contextClick Method:

Double click and Right Click in Selenium with Examples and How To Perform Right Click Action (Context Click) In Selenium and Select an Option from the Right-Click Menu in Selenium Webdriver and Perform Right Click Action Using WebDriver