VulpesOS/gaia/apps/gallery/test/marionette/lib/system.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

49 lines
1.2 KiB
JavaScript
Executable file

/* global module */
'use strict';
function System(client) {
this.client = client;
}
module.exports = System;
System.Selector = Object.freeze({
actionMenu: 'form[data-z-index-level="action-menu"]',
button: 'form[data-z-index-level="action-menu"] > menu > button'
});
System.prototype = {
client: null,
get actionMenu() {
// Switch to the system app first.
this.client.switchToFrame();
this.waitForOptionsToDisplay();
return this.client.findElement(System.Selector.actionMenu);
},
switchToApp: function(appOrigin) {
this.client.switchToFrame();
this.client.apps.switchToApp(appOrigin);
},
waitForOptionsToDisplay: function() {
this.client.waitFor(function() {
return this.client.helper.waitForElement(
System.Selector.button).displayed();
}.bind(this));
},
/**
* @return {Marionette.Element} menu option that has same text as appName.
*/
menuOptionButton: function(appName) {
var options = this.actionMenu.findElements(System.Selector.button);
for (var i = 0; i < options.length; i++) {
var menuOption = options[i];
if (menuOption.text() === appName) {
return menuOption;
}
}
}
};