使用Selenium 2中的高級用戶交互API(http://code.google.com/p/selenium/wiki/AdvancedUserInteractions)打開自定義上下文菜單時出現問題。Selenium中的上下文點擊2.2
下面是C#代碼:
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.flickr.com/photos/davidcampbellphotography/4581594452/");
IWebElement photoDiv = driver.FindElement(By.Id("photo"));
Actions actions = new Actions(driver);
var context = actions.ContextClick(photoDiv).Build();
context.Perform();
不過這段代碼沒有打開上下文菜單,但只需點擊圖像上。
還有很多其他交互工作正常,就像在this blogpost。
我在Windows XP Selenium版本2.2上使用Firefox 5。
如有任何建議,請提前致謝。
UPDATE: 但是,here的代碼也是這樣(左鍵單擊而不是上下文單擊)。
ILocatable loc = (ILocatable)photoDiv;
IMouse mouse = ((IHasInputDevices)driver).Mouse;
mouse.ContextClick(loc.Coordinates);
mouse.MouseMove(loc.Coordinates, 15, 15);
看起來像一個錯誤。
謝謝!我將安裝Selenium並檢查它,並重新測試代碼以查看錯誤是否仍然存在。將在幾天內回報:) –