LiquidTest has a range of methods for locating elements on a page.
At it's simplest you can use the text on a control or link to reference it.
At it's most complex you can use XPath expressions.
LiquidTest has different options when it comes to XPaths. Ideally LiquidTest tries to locate the shortest, nicest XPath for a given node. The XPath locator performs the following search:
XPath
Text
ID
Name
Value
At it's simplest you can use the text on a link or button to identify it. This works well if the text on the element is unique, it doesn't work so well if you have a list of results with an edit link next to each. For example:
If your page looks like this
HTML
<a href="edit.html">Edit</a>
<input type="submit" value="Save"/>
<label for="foo_name">Name</label>
<input type="text" id="foo_name" value=""/>
<input type="radio" name="signup" value="email" id="signup_email"/>
<label for="signup_email">Contact me via e-mail</label>
then you can address elements as follows
Addresses
click("Save") // will submit the form
click("Edit") // will click the edit link
click("Name") // will put focus in text control
click("Contact me via e-mail") // will select the appropriate radio button
Pros:
Cons:
Can only be used for elements with unique text.
The text of labels, links and buttons may change over time, breaking any tests.
Alternatively if you know the HTML id of the button or link or the HTML name of a form element. For example:
HTML
<input name="widget[text]" id="widget_text" value=""/>
Addresses
click("widget[text]") // will click the text field
click("widget_text") // will click the text field
Radio buttons or check buttons can be addressed by their value.
HTML
<input type="radio" name="widget[type]" value="shonky"/>
<input type="radio" name="widget[type]" value="ultra_premium"/>
Addresses
click("ultra_premium") // will click the second radio button
Pros:
Cons:
* Harder to read than the simple style.
* Less susceptible to changes in the HTML
Finally you can use XPaths to address things. For example:
HTML
<html><body><a id="home_link" href="/home">My Home</a></body></html>
Addresses
click("/HTML/A") // will click the link
click("//A[1]") // will click the link
click("id('home_link')") // will click the link
Pros:
Cons:
Xpaths do not support traversing frames which is a common requirement on sites that use iframes or
(shudder) framesets. To support this LiquidTest has a method for specifying searches inside iframes. A
string in the form id('iframe1_h')–>Edit is interpreted as find the frame container at id('iframe1_h') (an iframe) then find the element with Edit inside the frame document (say a link).
Something about the fact that some ids are unlikely to be good test candidates if they're based on database ids or generated with layout information by web frameworks.
LiquidTest Recording and Element addressing is controlled through the LiquidTest Preferences UI.
In summary the method used to process an address on replay is:
Split the address up into multiple addresses if it spans frames.
For each address:
Check if it is an xpath
Check if it is the text of an element (say a button or link)
Check if it is an id of an element
Check if it is the name of a form element (say a text field)
Check if it the value of a form element (say the text value of a submit button, or the value of a radio button)
|
|
News / Events
|
|
|
|
|
|
|
|
Recently Added Content
|
|
|
|
|