2011-08-18 46 views

回答

1

它將取決於菜單如何實現(即將觸發按鈕出現的事件),但您應該查看focusmouseOver硒方法。

I.e.這樣做

this.selenium.mouseOver(element); 

其中element指菜單,然後在按鈕上做一個click。如果mouseOver不起作用(即該按鈕不可用),請嘗試focus

0

目前還不清楚您是否使用Selenium RC或Selenium 2和WebDriver。

我只能對後者說話,但您可以使用操作來移動鼠標並單擊。基本思想是定義一個對象,它是一系列的動作,然後執行這些動作。

關於如何使用這些介紹是http://code.google.com/p/selenium/wiki/AdvancedUserInteractions,和良好的書面記錄與Python的例子是http://www.theautomatedtester.co.uk/blog/2011/selenium-advanced-user-interactions.html

這聽起來像你的情況,你會碰到這樣的:

Actions menuClick = new Actions(driver); 

builder.MoveToElement(menuElement) 
    .MoveToElement(buttonElement) 
    .click(buttonElement) 

Action menuClick = builder.build(); 

menuClick.perform(); 
相關問題