$
The $
command is a short way to call the element
command in order
to fetch a single element on the page. It returns an object that with an extended prototype to call
action commands without passing in a selector. However if you still pass in a selector it will look
for that element first and call the action on that element.
Using the wdio testrunner this command is a global variable else it will be located on the browser object instead.
You can chain $
or $$
together in order to walk down the DOM tree.
Usage
Parameters
Param |
Type |
Details |
selector |
String |
selector to fetch a certain element |
Example
index.html1 2 3 4 5 6
| <ul id="menu"> <li><a href="/">Home</a></li> <li><a href="/">Developer Guide</a></li> <li><a href="/">API</a></li> <li><a href="/">Contribute</a></li> </ul>
|
$.js1 2 3 4 5 6 7
| it('should get text from a menu link', function () { var text = $('#menu');
console.log(text.$$('li')[2].$('a').getText()); console.log(text.$$('li')[2].getText('a')); });
|