- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to perform right click on an element with Actions in Selenium?
We can perform right click on an element in Selenium with the help of Actions. In order to perform the right click action we will use contextClick () method. First we need to move to the specific element with the help of moveToElement() method then will do the right click with contextClick() method. Finally use build().perform() to execute all the steps.
Example
import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Action; import org.openqa.selenium.interactions.Actions; import java.util.concurrent.TimeUnit; public class RightClick{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); String url = "https://www.tutorialspoint.com/questions/index.php"; driver.get(url); driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS); // contextClick() method for right click to an element after moving the //mouse to with the moveToElement() Actions a = new Actions(driver); a.moveToElement(driver.findElement(By.xpath(“input[@type=’text’]))). contextClick(). build().perform(); driver.quit(); } }
- Related Articles
- How to perform right click on an element in Selenium with python?
- How to perform double click on an element in Selenium with python?
- How to perform double click on an element in Selenium?
- How to perform right click using Selenium ChromeDriver?
- How to perform mouseover action on an element in Selenium?
- How to perform releasing a mouse on an element in Selenium with python?
- How to click on hidden element in Selenium WebDriver?
- How to use JavaScript in Selenium to click an Element?
- How to perform mouse movement to an element in Selenium with python?
- How to create right click using selenium?
- How do you click on an element which is hidden using Selenium WebDriver?
- How to click on a link in Selenium with python?
- How to click on a link in Selenium?
- How to click on a button with Javascript executor in Selenium with python?
- How to click on image in selenium webdriver Python?

Advertisements