2014-01-31 79 views

回答

0

簡單的例子:

driver.get("http://www.sbsddsd.com/"); 

     driver.manage().timeouts().implicitlyWait(300, TimeUnit.SECONDS); 

     Actions act = new Actions(driver); 

WebElement parentMenu = driver.findElement(By.xpath("//div[@id='abc')]")); 

act.contextClick(parentMenu).build().perform(); 

     act.sendKeys(Keys.ARROW_DOWN).build().perform(); 

     act.sendKeys(Keys.ARROW_DOWN).build().perform(); 

     act.sendKeys(Keys.ENTER).build().perform(); 
0

在所有的webdriver先進的交互都是通過動作類處理。我給你下面一個例子:

Actions builder=new Actions(driver); 
builder.moveToElement(WebElement).click(); 
builder.perform();