Mozmill Base Object Interfaces 编辑
At the top of many Mozmill tests you will see a line that contains a setupModule function with something that looks like the following code in it: controller = mozmill.getBrowserController(); This creates a "controller" object for the test to use. The controller object is the heart of all Mozmill interfaces in that it allows you to completely control the application under test. However, this makes use of a global object called mozmill to instantiate the controller. The mozmill object API provides many convenience methods to help you get started testing specific applications.
Method overview
Attributes
Attribute | Type | Description |
---|---|---|
platform | object | The name of the platform according to the Gecko subsystem, i.e. Mac == Darwin, Windows == winnt, linux == linux. For more specifc testing use the "is" attributes below. |
isWindows | boolean | True if the current platform is a Windows operating system |
isLinux | boolean | True if the current platform is a Linux operating system |
isMac | boolean | True if the current platform is a Mac OS X operating system |
wm | nsIWindowMediator | Shortcut to the nsIWindowsMediator service, for an example of use see controller.MozMillController below |
appInfo | nsIXULAppInfo | Shortcut to the nsIXULAppInfo service. |
Browser Methods
getBrowserController()
Gets a new browser controller for the currently open browser window. If no window is open, it opens a new window and returns a controller for that. Supported in Firefox and Seamonkey.
controller getBrowserController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.getBrowserController();
newBrowserController()
Forces creation of a new browser window and returns a controller for it, regardless of how many other browser windows are open. Supported in Firefox and Seamonkey.
controller newBrowserController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.newBrowserController();
getDownloadsController()
Instantiates the Downloads window and returns a controller for that or returns a controller to an already opened Downloads window. Supported in Firefox and Seamonkey.
controller getDownloadsController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.getDownloadsController();
Mail Methods
getAddrbkController()
Gets a controller for the current Thunderbird Addressbook window. If one is not open, it opens a window and returns a controller for that. Supported in Thunderbird.
controller getAddrbkController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.getAddrbkController();
newAddrbkController()
Forces the system to create a new addressbook window and returns a controller for that. Supported in Thunderbird.
controller newAddrbkController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.newAddrbkController();
getMail3PaneController()
Gets a controller for the current Thunderbird window. If one is not open, it opens a window and returns a controller for that. Supported in Thunderbird.
controller getMail3PaneController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.getMail3PaneController();
newMail3PaneController()
Forces the system to create a new main Thunderbird window and returns a controller for that. Supported in Thunderbird.
controller newMail3PaneController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.newMail3PaneController();
General Methods
getAddonsController()
Creates a controller for the currently open Add-Ons window, if one is not open, it opens one and returns the controller for that. Supported in all applications that use the toolkit Extension Manager to manage addons.
controller getAddonsController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.getAddonsController();
getPreferencesController()
Creates a controller for the currently open Preferences window, if one is not open, it opens one and returns the controller for that. Supported in all applications.
controller getPreferencesController();
Parameters
None
Return value
controller
Returns a controller object for the window.
Example
controller = mozmill.getPreferencesController();
controller.MozMillController()
Creates a controller for the given window. This works on all supported applications and allows you to create controllers for windows that do not have a convenience method above. Supported in all applications.
controller controller.MozMillController(in nsIDOMWindow
window);
Parameters
window
- The DOM Window you wish to wrap into a controller object
Return value
controller
Returns a controller object for the window.
Example
// Creates a controller for the browser's page information dialog.
// It assumes that you've already clicked on the proper icons to launch the dialog.
let window = mozmill.wm.getMostRecentWindow('Browser:page-info');
let pageInfoController = new mozmill.controller.MozMillController(window);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论