Michael, Aus, Gareth, Johan
Engineers/QA for Connected Devices
Testing Gurus (them, not me)
// Fetch DOM from current app.
client.findElement('#my-id');
// Send JS to Mulet to execute.
client.executeScript(function(){
// do stuff!
});
// Wait for something to happen.
client.waitFor(function() {
return true || false; // true is finished, false keeps going
});
// Takes screenshot, automatically called on test timeout.
client.screenshot();
// Grab remote DOM element
var element = client.findElement('#some-element");
// Get element box information.
var rect = element.rect();
console.log(rect.x, rect.y, rect.width, rect.height);
// Tap it!
element.tap();
assert(element.displayed(), 'element should be on screen');
// Run remote script on element.
element.scriptWith(function (el) {
el.remove();
});
// Create our actions helper.
var Actions = require('marionette-client').Actions;
var actions = Actions(client);
// Common actions.
actions.longPress(element, 3).perform();
actions.flick(element, 0, 0, 0, elementHeight).perform();
// Complex action.
var action = actions.press(element);
if (client.findElement('body').getAttribute('dir') === 'RTL') {
action.moveByOffset(-100, 0);
} else {
action.moveByOffset(100, 0);
}
action.release.perform();
// Waits on an element to come onscreen.
client.helper.waitForElement('#my-element');
// Waits on an element to not be onscreen.
client.helper.waitForElementToDisappear('#my-element');
// Focuses input, fills input with text.
client.helper.fillInputField('input.some-class', 'Michael');
const EMAIL_ORIGIN = 'app://email.gaiamobile.org';
// Manipulate app contexts.
client.apps.lauch(EMAIL_ORIGIN);
client.apps.switchToApp(EMAIL_ORIGIN);
client.findElement('#send-button').tap();
client.apps.close(EMAIL_ORIGIN);
// Load class libraries.
var system = client.loader.getAppClass('system');
var email = client.loader.getAppClass('email');
// Bring up the email compose screen.
email.tapCompose();
var sendButton = email.sendButton; // waits for send button
// Make sure send button disappears when turning off screen.
system.turnScreenOff();
client.waitForElementToDissapear(sendButton);
var assert = require('assert');
marionette('Test file description', function() {
var client = marionette.client();
var system;
suite('description of test suite', function() {
setup(function() {
system = client.getAppClass('system');
system.waitForFullyLoaded();
});
test('test interaction', function() {
assert(system.statusbar, 'statusbar should be visible');
}) /* ... */ });
});
marionette('', function() {
var client = marionette.client();
suite('new message', function() {
test('is created', function() {
var newButton = client.findElement('#threads-composer-link');
newButton.tap();
panel = client.helper.waitForElement('.panel-ConversationView');
client.waitFor(function() {
return panel.rect.x === 0;
});
input = client.helper.waitForElement('#messages-to-field [contenteditable=true]:last-child');
input.tap();
input.sendKeys('test user');
input.sendKeys(KEYS.ENTER);
input2 = client.helper.waitForElement('#messages-input');
input2.tap();
input2.sendKeys('test message');
sendButton = client.helper.waitForElement('#messages-send-button');
sendButton.tap();
message = client.helper.waitForElement('.message')[0];
assert.equal(message.text(), 'test message');
}) /* ... */ });
});
marionette('', function() {
var client = marionette.client();
suite('new message', function() {
test('is created', function() {
var newMessage = message.goToNewMessage();
newMessage.addNewRecipient('test user');
newMessage.typeMessage('test message');
newMessage.send();
assert.equal(newMessage.messages[0], 'test message');
}) /* ... */ });
});