In this post, we will discuss how to perform right click if we are using Selenium WebDriver for automation testing.
For this purpose, we need to use Action class . Under Action class various method are defined for serving various actions that are needed to be performed while testing. For right click operation, we have contextClick() method available under Actions class. Below is the sample code :
- Actions action = new Actions(driver);
- //Actions class take WebDriver type object as argument
- action .moveToElement(webElement).perform();
- action .contextClick().perform();