QA/TDAI/Gristmill/Boilerplate Explained: Difference between revisions

Jump to navigation Jump to search
no edit summary
(New page: <small><< Back to Gristmill Main Page</small> = The BoilerPlate = Here is the generated code from the "Test->New Boilerplate" step in the Gristmill UI. We'll go thr...)
 
No edit summary
Line 22: Line 22:
The first block of code sets up the proper environment for your test.
The first block of code sets up the proper environment for your test.


<pre>var elementslib = {}; Components.utils.import('resource://mozmill/modules/elementslib.js', elementslib);</pre>
<pre>var elementslib = {};
Components.utils.import('resource://mozmill/modules/elementslib.js', elementslib);</pre>
This statement imports a Javascript library file to the scope of your test.  This means that you can now access all the exported functions from the elementslib.  The elementslib is used to locate and grab UI elements to interact with.
This statement imports a Javascript library file to the scope of your test.  This means that you can now access all the exported functions from the elementslib.  The elementslib is used to locate and grab UI elements to interact with.


<pre>var controller = {}; Components.utils.import('resource://mozmill/modules/controller.js', controller);</pre>
<pre>var controller = {};
Components.utils.import('resource://mozmill/modules/controller.js', controller);</pre>
This is the same thing, except we are loading the controller library.  The controller allows us the ability to perform interactions on UI elements.
This is the same thing, except we are loading the controller library.  The controller allows us the ability to perform interactions on UI elements.


Line 49: Line 51:


<pre>var test_foo = function(){</pre>
<pre>var test_foo = function(){</pre>
This names our test "test_foo" and creates a function.  Each test is one function, named test_<something>. Try to name them descriptively for what you are testing.  The test function can call other functions, but other functions won't be called by Mozmill unless they begin with "test_".
This names our test "test_foo" and creates a function.  Each test is one function, named test_<something>. Try to name them descriptively for what you are testing.  The test function can call other functions, but other functions won't be called by Gristmill unless they begin with "test_".


<pre>browser.type(new elementslib.ID(_w.document, 'urlbar'), "http://www.heckyes.com");</pre>
<pre>browser.type(new elementslib.ID(_w.document, 'urlbar'), "http://www.heckyes.com");</pre>
Confirmed users
3,816

edits

Navigation menu