Bindings & Commands
WebdriverIO differentiates between two different method types: protocol bindings and commands. Protocol bindings
are the exact representation of the JSONWire protocol interface. They expect the same parameters as described
in the protocol docs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| client.element().then(function(result) { console.log(result);
});
|
Since version 2.0.0
WebdriverIO has all JSONWire protocol bindings implemented and even a whole bunch of Appium
specific ones for mobile testing.
All other methods like getCssProperty
or dragAndDrop
using these commands to provide handy functions who simplify
your tests to look more concise and expressive. So instead of doing this:
1 2 3 4 5 6 7
| client.element('#myElem').then(function(res) { assert(err === null); client.elementIdCssProperty(res.value.ELEMENT, 'width').then(function(res) { assert(res.value === '100px'); }); });
|
you can simply do this:
1 2 3 4 5 6 7 8 9 10 11
| client.getCssProperty('#myElem', 'width').then(function(width) { assert(width.parsed.value === 100);
});
|
It not only shortens your code it also makes the return value testable. You don’t have to worry about how to combine
the JSONWire bindings to achieve a certain action, just use the command methods.