Skip to content

Commit

Permalink
Bug 1241067: Change string concats to use string templating. r=ato
Browse files Browse the repository at this point in the history
This standardises the way we generate strings in element.js

--HG--
extra : rebase_source : e99d863cdd1e912b20d27b5dcdfc962e74d8fae0
  • Loading branch information
David Burns committed Jan 21, 2016
1 parent 5b18d8a commit 6682722
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions testing/marionette/elements.js
Expand Up @@ -116,7 +116,7 @@ ElementManager.prototype = {
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();
Expand Down Expand Up @@ -342,7 +342,7 @@ ElementManager.prototype = {
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.");
Expand All @@ -362,11 +362,11 @@ ElementManager.prototype = {
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);
}
Expand Down Expand Up @@ -466,13 +466,13 @@ ElementManager.prototype = {
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:
Expand Down Expand Up @@ -522,7 +522,7 @@ ElementManager.prototype = {
break;

default:
throw new InvalidSelectorError("No such strategy: " + using);
throw new InvalidSelectorError(`No such strategy: ${using}`);
}

return element;
Expand All @@ -547,14 +547,14 @@ ElementManager.prototype = {
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);
Expand Down Expand Up @@ -590,7 +590,7 @@ ElementManager.prototype = {
}
break;
default:
throw new InvalidSelectorError("No such strategy: " + using);
throw new InvalidSelectorError(`No such strategy: ${using}`);
}
return elements;
},
Expand Down

0 comments on commit 6682722

Please sign in to comment.