How to write rightclick method in selenium testng -


how rightclick on webelement selenium testng? have given example doubleclick, likewise need rightclick method.please give me best one.

public static void doubleclickon(string objlocator1){                                 try             {             findwebelement(objlocator1);               actions actions = new actions(driver);             org.openqa.selenium.interactions.action action = actions.doubleclick(webelement).build();             action.perform();             app_logs.debug("double clicked on "+locatordescription);             //system.out.println(locator);             }             catch(exception e)             {                 e.printstacktrace();                 app_logs.debug("fail : locator "+locator+" of description "+locatordescription+": not exists in webpage:");                 reporting.fail("fail : locator "+locator+" of description "+locatordescription+": not exists in webpage:");              } 

}

thanks in advance

try this:-

assuming "objlocator1" consists of xpath of webelement right-click on.

public static void rightclickon(string objlocator1){                                 try             {             findwebelement(objlocator1);               actions actions = new actions(driver);                 actions.contextclick(driver.findelement(by.xpath(objlocator1)));             actions.perform();              app_logs.debug("context clicked on "+locatordescription);             //system.out.println(locator);             }             catch(exception e)             {                 e.printstacktrace();                 app_logs.debug("fail : locator "+locator+" of description "+locatordescription+": not exists in webpage:");                 reporting.fail("fail : locator "+locator+" of description "+locatordescription+": not exists in webpage:");              } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -