Created
February 6, 2015 04:43
-
-
Save udayanem/7f808f052604b56d319d to your computer and use it in GitHub Desktop.
How to right click on a webelement using webdriver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.TimeUnit; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.Keys; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.interactions.Actions; | |
public class ActBuilderRightClk | |
{ | |
public static void main(String[] args) throws InterruptedException | |
{ | |
WebDriver driver=new FirefoxDriver(); | |
driver.get("https://in.yahoo.com"); | |
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); | |
WebElement cricket=driver.findElement(By.xpath("//ul[@class='fz-xs']/li[4]")); | |
Actions action=new Actions(driver); | |
action.contextClick(cricket).sendKeys(Keys.DOWN).sendKeys(Keys.ENTER).perform(); //short form | |
// action.moveToElement(cricket).contextClick().sendKeys(Keys.DOWN).sendKeys(Keys.ENTER).perform(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment