QA/TDAI/Gristmill/Gristmill API: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
This explains the Gristmill APIs that you can use in your tests.
This explains the Gristmill APIs that you can use in your tests.


== Controller APIs ==
These APIs are from the Mozmill object and give you different controllers for different parts of the application
===mozmill.getBrowserController()===
Returns a controller that functions over the entire browser window (gets the most recent browser window)
===mozmill.getPreferencesController()===
Returns a controller for the preferences window and opens that window.  You can then use the specialized controller.tabs.<tabname>.button object to simulate a click on each preference pane tab.  For example the following code demonstrates a click on the Content tab of the preferences window:
<pre> controller = mozmill.getPreferencesController();
controller.click(new elementslib.Elem(controller.tabs.Content.button));</pre>
===mozmill.getAddonsController()===
Returns a controller for the Add-Ons window and opens the window.
===mozmill.newBrowserController()===
Opens a new browser window and returns a controller for it


== Action APIs ==
== Action APIs ==
Line 138: Line 153:
===controller.refresh()===
===controller.refresh()===
Causes the browser to refresh the current document.
Causes the browser to refresh the current document.
===controller.tabs.getTab(index)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|index
|The 0 based index of the tab you want the document for.
|}
This returns the content document object (i.e. the DOM) for the tab at the specified index.
===controller.tabs.activeTab()===
Returns the content document object for the active tab
===controller.tabs.selectTab(index)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|index
|The 0 based index of the tab you want the document for.
|}
Causes the tab at the specified index to be given the current focus.  Simulates a click on the specified tab header.  '''NOTE: Not working currently'''


== Wait APIs ==
== Wait APIs ==
===controller.sleep(milliseconds)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|milliseconds
|Number of milliseconds to sleep the test
|}
Waits the specified number of milliseconds before calling the next instruction in the test.
===controller.waitForEval(expression, timeout, interval, subject)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|expression
|The expression that you want to wait until it evaluates to True
|-
|timeout
|The maximum time you want to wait in milliseconds. Defaults to 30 seconds if not specified
|-
|interval
|How long you want to wait between checking whether or not the expression now evaluates to true. Defaults to 100 milliseconds if not specified.
|-
|subject
|Used by the "waitForElement" call.  You may leave this unspecified.
|}
Takes an expression that should evaluate to true.  For example, perhaps the color attribute on the element named "box" should be purple, and once it is, we can continue with the test.  In that case, we would use the following:
<pre>controller.waitForEval('purple'==document.getElementById('box').getAttribute('color'),200, 15000);</pre>
This will evaluate whether or not the box is purple every 200 milliseconds, and will timeout after 15 seconds.  If the timeout occurs the function returns false.  If the expression does evaluate to 'true' before the timeout happens, then the function returns true.
===controller.waitForElement(elem, timeout, interval)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|elem
|The element you are waiting for
|-
|timeout
|The maximum time you want to wait in milliseconds. Defaults to 30 seconds if not specified
|-
|interval
|How long you want to wait between checking whether or not the expression now evaluates to true. Defaults to 100 milliseconds if not specified.
|}
This is a specialized call of the waitForEval function above.  It will wait until the specified element exists.  If it times out, it will return false.  If it succeeds, it returns true.


== Assert APIs ==
== Assert APIs ==
Confirmed users
3,816

edits