How to perform Right click on the Web element and select an option from context menu in Selenium Webdriver?

Step1: Store the path of web-element to be right clicked and web-element to be selected from context menu.
        

      WebElement rightClickelement = driver.findElement(by.---( ));  
WebElement contextMenuelement = driver.findElement(by.---( ));

Step2: Use Action class
          

       Actions actions = new Actions(driver);  
Action action = actions.contextclick(rightClickelement).build( );
action.perform( );

Step3: Click on the element  from the Context menu of the web element.
          

    contextMenuelement.click( );   

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s