diff --git a/ide/main/src/content/debugger.js b/ide/main/src/content/debugger.js index dc5653f869980..1c8c1038bcaf5 100644 --- a/ide/main/src/content/debugger.js +++ b/ide/main/src/content/debugger.js @@ -205,6 +205,53 @@ Debugger.prototype.showElement = function (locator) { this.runner.showElement(locator); }; +Debugger.prototype.selectElement = function () { + this.init(); + var button = document.getElementById("selectElementButton"); + var help = document.getElementById("selectElementTip"); + if (this.targetSelecter) { + this.targetSelecter.cleanup(); + this.targetSelecter = null; + return; + } + var self = this; + var isRecording = this.editor.recordingEnabled; + if (isRecording) { + this.editor.setRecordingEnabled(false); + } + button.label = "Cancel"; + help.removeAttribute("style"); + this.targetSelecter = new TargetSelecter(function (element, win) { + if (element && win) { + var locatorBuilders = new LocatorBuilders(win); + var target = locatorBuilders.buildAll(element); + locatorBuilders.detach(); + if (target != null && target instanceof Array) { + if (target[0]) { + self.editor.treeView.updateCurrentCommand('targetCandidates', target); + } else { + alert("LOCATOR_DETECTION_FAILED"); + } + } + + } + self.targetSelecter = null; + }, function () { + button.label = "Select"; + help.setAttribute("style", "display: none;"); + if (isRecording) { + self.editor.setRecordingEnabled(true); + } + }); +}; + +Debugger.prototype.unload = function () { + if (this.targetSelecter) { + this.targetSelecter.cleanup(); + this.targetSelecter = null; + } +}; + /* * Use to reload the Selenium Core API * and its overrides and extensions (user-extensions file) diff --git a/ide/main/src/content/editor.js b/ide/main/src/content/editor.js index c75ce656fa6e5..13b9c1b442bdb 100644 --- a/ide/main/src/content/editor.js +++ b/ide/main/src/content/editor.js @@ -501,6 +501,7 @@ Editor.prototype.log = Editor.log = new Log("Editor"); Editor.prototype.unload = function () { this.app.saveState(); + this.selDebugger.unload(); this.deregisterRecorder(); top.controllers.removeController(Editor.controller); diff --git a/ide/main/src/content/selenium-ide.xul b/ide/main/src/content/selenium-ide.xul index 2d7728fdfa48f..37e2484a7b318 100644 --- a/ide/main/src/content/selenium-ide.xul +++ b/ide/main/src/content/selenium-ide.xul @@ -132,12 +132,19 @@ limitations under the License.