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

From MozillaWiki
< QA‎ | TDAI‎ | Gristmill
Jump to navigation Jump to search
No edit summary
No edit summary
Line 138: Line 138:
===controller.refresh()===
===controller.refresh()===
Causes the browser to refresh the current document.
Causes the browser to refresh the current document.


== Wait APIs ==
== Wait APIs ==


== Assert APIs ==
== Assert APIs ==
Use these APIs to test see if certain properties are true on given elements.  Think of it as asserting that some statement about the page in question is true.
===controller.assertText(el, text)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|el
|An element that the assert will verify
|-
|text
|The text that the element must have within it.
|}
Returns True if the text exists in the given element, false otherwise.
===controller.assertNode(el)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|el
|An element that the assert will verify the existence of
|}
Returns true if the node in question exists, false otherwise.
===controller.assertValue(el, value)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|el
|An element that the assert will verify the existence of
|-
|value
|The value that the element should have
|}
Returns true if the node in question contains the provided value. (i.e. checked, selected etc)
===controller.assertJS(js)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|js
|Assert
|}
Executes a piece of javascript.  The javascript must return true or false.  And this will return that value as the return of the assert.
===controller.assertNode(el, value)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|el
|A select element (a drop down)
|-
|value
|The value that is selected in the drop down.
|}
Returns true if the currently selected item is equal to the given value
===controller.assertChecked(el)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|el
|An checkbox element
|}
Returns true if the node in question is checked, false otherwise.
===controller.assertProperty(el, attrib, value)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|el
|An element that the assert will work with
|-
|attrib
|The name of the attribute that we wish to check
|-
|value
|The value we expect that attribute to have
|}
Returns true if the element's "attrib" property has the specified value, false otherwise.
===controller.assertImageLoaded(el)===
{| class="standard-table"
|-
|class="header"|Parameters
|-
|el
|An image to check
|}
Returns true if the given image is loaded, false otherwise

Revision as of 00:28, 15 August 2008

This explains the Gristmill APIs that you can use in your tests.


Action APIs

controller.open(url, elementToWaitFor)

Parameters
url A URL to open

Open is a mechanism to open a the given URL in the currently focused tab/window of the window that is under control by the controller.

controller.keypress(el, keycode)

Parameters
el An element that the event will be targeted at
keycode The keycode that you wish to send to that element.

Sends a single key event to the designated element object.

controller.type(el, text)

Parameters
el An element that the event will be targeted at
text The text to be typed into the given element object

Fires type events (simulating both the keydown and keyup) at the given element object. If the text is longer than the available length on the element object, the text will be truncated to fit.

controller.click(el)

Parameters
el An element that the event will be targeted at

Sends a single mouse click to the element object

controller.select(el)

Parameters
el An element that the event will be targeted at

Selects the specified option and triggers the relevant selection events on the given element object. TODO: Determine if this code works.

controller.mousedown(el)

Parameters
el An element that the event will be targeted at

Sends the "mousedown" (mouse button depressed) event to the element object.

controller.mouseup(el)

Parameters
el An element that the event will be targeted at

Sends the "mouseup" (mouse button released) event to the element object.

controller.mouseover(el)

Parameters
el An element that the event will be targeted at

Sends the "mouseover" (mouse drug over an element) event to the element object.

controller.mouseout(el)

Parameters
el An element that the event will be targeted at

Sends the "mouseout" (mouse drug off an element) event to the element object.

controller.check(el)

Parameters
el An element that the event will be targeted at

Causes the element to be "checked" if it is a checkbox. If it is not a checkbox, it causes a click on the element.

controller.radio(el)

Parameters
el An element that the event will be targeted at

Selects a radio button element. If the element is not a radio button entry, then it causes a generic click against that element.

controller.doubleclick(el)

Parameters
el An element that the event will be targeted at

Causes a doubleclick event to be fired at the element object.

Browser Shortcut Action APIs

controller.goBack()

Causes the browser to go back one step in history.

controller.goForward()

Causes the browser to go forward one step in history.

controller.refresh()

Causes the browser to refresh the current document.

Wait APIs

Assert APIs

Use these APIs to test see if certain properties are true on given elements. Think of it as asserting that some statement about the page in question is true.

controller.assertText(el, text)

Parameters
el An element that the assert will verify
text The text that the element must have within it.

Returns True if the text exists in the given element, false otherwise.

controller.assertNode(el)

Parameters
el An element that the assert will verify the existence of

Returns true if the node in question exists, false otherwise.

controller.assertValue(el, value)

Parameters
el An element that the assert will verify the existence of
value The value that the element should have

Returns true if the node in question contains the provided value. (i.e. checked, selected etc)

controller.assertJS(js)

Parameters
js Assert

Executes a piece of javascript. The javascript must return true or false. And this will return that value as the return of the assert.

controller.assertNode(el, value)

Parameters
el A select element (a drop down)
value The value that is selected in the drop down.

Returns true if the currently selected item is equal to the given value

controller.assertChecked(el)

Parameters
el An checkbox element

Returns true if the node in question is checked, false otherwise.

controller.assertProperty(el, attrib, value)

Parameters
el An element that the assert will work with
attrib The name of the attribute that we wish to check
value The value we expect that attribute to have

Returns true if the element's "attrib" property has the specified value, false otherwise.

controller.assertImageLoaded(el)

Parameters
el An image to check

Returns true if the given image is loaded, false otherwise