2011-10-04 26 views
2

我一直在試圖打開上下文菜單使用硒2.我已經試過的那些事我自動化測試分別是: -的webdriver :: contextClick(webElement)未打開上下文菜單

WebDriver driver = new FirefoxDriver(); 
Actions actions = new Actions(driver); 
//location is = "largeImageF-img" 
WebElement webElement = driver.findElement(By.id(location)); 
actions.contextClick(webElement); 

它不開放上下文菜單。

我嘗試使用

selenium.contextMenu(xpath); 
//selenium was instantiated using WebDriverBackedSelenium 

任何指導,將不勝感激。謝謝

回答

2

Action類實現builder pattern。因此,您可以鏈接多個呼叫以創建一個操作序列。要執行它們,必須在最後調用perform()

actions.contextClick(webElement).perform(); 

您的代碼不執行的操作。

+0

我想感謝您的回覆。我確實明白我需要使用perform()。但不知道爲什麼行動沒有被排除。我使用的步驟是: WebDriver driver = new FirefoxDriver(); driver.navigate()。(「http:// ....」); 操作actions = new Actions(driver); WebElement webElement = driver.findElement(By.id(location)); actions.contextClick(webElement).method(); 我錯過了什麼。謝謝, – arin

+0

@ user978301:對不起,您的評論沒有意義。沒有方法Actions.method()。另外,如果您需要修改/更正您的問題,請編輯您的問題。這樣每個人都看到你的改正。 – sleske

+0

@ user978301:它應該是actions.contextClick(webElement).perform()而不是actions.contextClick(webElement).method() –

相關問題