How to select a right click operation on a link or image and choose any option?
I know how to do it using SendKeys with below code:
WebElement o_Mail=driver.findElement(By.xpath("/html/body/center/form/table/tbody/tr/td[3]/a"));
Actions action=new Actions(driver);
action.contextClick(o_Mail).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
The drawback is here we should know how many times the DOWN button should be pressed.
But how can i select with option name which will be like below?
action.contextClick(o_Mail).perform();
WebElement o_element=driver.findElement(By.xpath("//option[contains(text(),'Open Link in New Tab')]"));
o_element.click();
You can use google main page and right click on Advance search and choose Open Link in New Tab?
Please help.