--- a/testing/marionette/elements.js
+++ b/testing/marionette/elements.js
@@ -111,17 +111,17 @@ ElementManager.prototype = {
* The window and an optional shadow root that contains the element
*
* @returns nsIDOMElement
* Returns the element or throws Exception if not found
*/
getKnownElement: function EM_getKnownElement(id, container) {
let el = this.seenItems[id];
if (!el) {
- throw new JavaScriptError("Element has not been seen before. Id given was " + id);
+ throw new JavaScriptError(`Element has not been seen before. Id given was ${id}`);
}
try {
el = el.get();
}
catch(e) {
el = null;
delete this.seenItems[id];
}
@@ -337,17 +337,17 @@ ElementManager.prototype = {
* Returns the element(s) by calling the on_success function.
*/
find: function EM_find(container, values, searchTimeout, all, on_success, on_error, command_id) {
let startTime = values.time ? values.time : new Date().getTime();
let rootNode = container.shadowRoot || container.frame.document;
let startNode = (values.element != undefined) ?
this.getKnownElement(values.element, container) : rootNode;
if (this.elementStrategies.indexOf(values.using) < 0) {
- throw new InvalidSelectorError("No such strategy: " + values.using);
+ throw new InvalidSelectorError(`No such strategy: ${values.using}`);
}
if (values.value == null) {
throw new InvalidSelectorError("Invalid selector value of null was used.");
}
let found;
try {
found = all ? this.findElements(values.using, values.value, rootNode, startNode) :
this.findElement(values.using, values.value, rootNode, startNode);
@@ -357,21 +357,21 @@ ElementManager.prototype = {
let type = Object.prototype.toString.call(found);
let isArrayLike = ((type == '[object Array]') || (type == '[object HTMLCollection]') || (type == '[object NodeList]'));
if (found == null || (isArrayLike && found.length <= 0)) {
if (!searchTimeout || new Date().getTime() - startTime > searchTimeout) {
if (all) {
on_success([], command_id); // findElements should return empty list
} else {
// Format message depending on strategy if necessary
- let message = "Unable to locate element: " + values.value;
+ let message = `Unable to locate element: ${values.value}`
if (values.using == ANON) {
message = "Unable to locate anonymous children";
} else if (values.using == ANON_ATTRIBUTE) {
- message = "Unable to locate anonymous element: " + JSON.stringify(values.value);
+ message = `Unable to locate anonymous element: ${JSON.stringify(values.value)}`;
}
on_error(new NoSuchElementError(message), command_id);
}
} else {
values.time = startTime;
this.timer.initWithCallback(this.find.bind(this, container, values,
searchTimeout, all,
on_success, on_error,
@@ -461,23 +461,23 @@ ElementManager.prototype = {
*/
findElement: function EM_findElement(using, value, rootNode, startNode) {
let element;
switch (using) {
case ID:
element = startNode.getElementById ?
startNode.getElementById(value) :
- this.findByXPath(rootNode, './/*[@id="' + value + '"]', startNode);
+ this.findByXPath(rootNode, `.//*[@id="${value}"]`, startNode);
break;
case NAME:
element = startNode.getElementsByName ?
startNode.getElementsByName(value)[0] :
- this.findByXPath(rootNode, './/*[@name="' + value + '"]', startNode);
+ this.findByXPath(rootNode, `.//*[@name="${value}"]`, startNode);
break;
case CLASS_NAME:
element = startNode.getElementsByClassName(value)[0]; //works for >=FF3
break;
case TAG:
element = startNode.getElementsByTagName(value)[0]; //works for all elements
@@ -517,17 +517,17 @@ ElementManager.prototype = {
break;
case ANON_ATTRIBUTE:
let attr = Object.keys(value)[0];
element = rootNode.getAnonymousElementByAttribute(startNode, attr, value[attr]);
break;
default:
- throw new InvalidSelectorError("No such strategy: " + using);
+ throw new InvalidSelectorError(`No such strategy: ${using}`);
}
return element;
},
/**
* Helper method to find. Finds all element using find's criteria
*
@@ -542,24 +542,24 @@ ElementManager.prototype = {
*
* @return nsIDOMElement
* Returns found elements or throws Exception if not found
*/
findElements: function EM_findElements(using, value, rootNode, startNode) {
let elements = [];
switch (using) {
case ID:
- value = './/*[@id="' + value + '"]';
+ value = `.//*[@id="${value}"]`;
case XPATH:
elements = this.findByXPathAll(rootNode, value, startNode);
break;
case NAME:
elements = startNode.getElementsByName ?
startNode.getElementsByName(value) :
- this.findByXPathAll(rootNode, './/*[@name="' + value + '"]', startNode);
+ this.findByXPathAll(rootNode, `.//*[@name="${value}"]`, startNode);
break;
case CLASS_NAME:
elements = startNode.getElementsByClassName(value);
break;
case TAG:
elements = startNode.getElementsByTagName(value);
break;
case LINK_TEXT:
@@ -585,17 +585,17 @@ ElementManager.prototype = {
case ANON_ATTRIBUTE:
let attr = Object.keys(value)[0];
let el = rootNode.getAnonymousElementByAttribute(startNode, attr, value[attr]);
if (el != null) {
elements = [el];
}
break;
default:
- throw new InvalidSelectorError("No such strategy: " + using);
+ throw new InvalidSelectorError(`No such strategy: ${using}`);
}
return elements;
},
}
this.elements = {};
elements.generateUUID = function() {
let uuid = uuidGen.generateUUID().toString();