Created
January 12, 2010 23:47
-
-
Save hugs/275767 to your computer and use it in GitHub Desktop.
Selenium IDE - Test Execution Workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Selenium IDE - Test Execution Workflow: | |
| *) Launch Selenium IDE | |
| *) Load/open a test case file. (Left as an excercise for the reader.) | |
| *) Press the green play button. Tool-tip reads "Play current test case". Under the hood, its id is 'play-button'. | |
| *) Which calls "cmd_selenium_play" | |
| Now let's see how deep the rabbit hole goes... (Massively edited to show the highlights) | |
| content/editor.js | |
| 199 doCommand : function(cmd) { | |
| 210 case "cmd_selenium_play": | |
| 212 editor.playCurrentTestCase(null, 0, 1); | |
| Hmm... what's "selDebugger"? | |
| content/editor.js | |
| 607 Editor.prototype.playCurrentTestCase = function(next, index, total) { | |
| 609 this.selDebugger.start(function(failed) { | |
| 621 } | |
| "selDebugger" is a "Debugger" object, which is set here: | |
| content/editor.js | |
| 95 this.selDebugger = new Debugger(this); | |
| "Debugger" is defined in a different file. Let's check out its "start" function. | |
| content/debugger.js | |
| 103 Debugger.prototype.start = function(complete, useLastWindow) { | |
| 109 this.init(); | |
| Let's look at "init()". (This is where the guts of Selenium Core get loaded into the "runner" namespace.) | |
| content/debugger.js | |
| 23 this.init = function() { | |
| 33 this.runner = new Object(); | |
| 34 this.runner.editor = this.editor; | |
| 44 this.runner.testCase = this.editor.getTestCase(); | |
| 45 const subScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] | |
| 46 .getService(Components.interfaces.mozIJSSubScriptLoader); | |
| 47 //subScriptLoader.loadSubScript('chrome://selenium-ide/content/selenium/selenium-logging.js', this.runner); | |
| 48 | |
| 49 subScriptLoader.loadSubScript('chrome://selenium-ide/content/selenium/scripts/selenium-api.js', this.runner); | |
| 50 subScriptLoader.loadSubScript('chrome://selenium-ide/content/selenium/scripts/selenium-commandhandlers.js', this.runner); | |
| 51 subScriptLoader.loadSubScript('chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js', this.runner); | |
| 52 subScriptLoader.loadSubScript('chrome://selenium-ide/content/selenium/scripts/selenium-browserbot.js', this.runner); | |
| 53 subScriptLoader.loadSubScript('chrome://selenium-ide/content/selenium/scripts/selenium-testrunner-original.js', this.runner); | |
| 54 if (this.editor.getOptions().userExtensionsURL) { | |
| 55 try { | |
| 56 ExtensionsLoader.loadSubScript(subScriptLoader, this.editor.getOptions().userExtensionsURL, this.runner); | |
| 57 } catch (error) { | |
| 58 this.log.error("error loading user-extensions.js: " + error); | |
| 59 } | |
| 60 } | |
| 61 subScriptLoader.loadSubScript('chrome://selenium-ide/content/selenium-runner.js', this.runner); | |
| 64 | |
| 87 } | |
| 88 } | |
| Now that init is done, let's continue "starting"... | |
| content/debugger.js | |
| 112 this.runner.start(this.editor.getBaseURL(), { | |
| 125 }; | |
| But where did "runner.start" come from? (It got loaded in selenium-runner.js in init().) | |
| Let's take a peak inside selenium-runner.js for a second. | |
| Darn thing is that we can't step debug further into the code (I use ChromeBug) | |
| because it was eval'd above by subScriptLoader. | |
| content/selenium-runner.js | |
| 269 function start(baseURL, handler, useLastWindow) { | |
| 270 //if (!stopAndDo("start", baseURL)) return; | |
| 271 resetCurrentTest(); | |
| 272 | |
| 273 selenium = createSelenium(baseURL, useLastWindow); | |
| 274 selenium.browserbot.selectWindow(null); | |
| 275 | |
| 276 commandFactory = new CommandHandlerFactory(); | |
| 277 commandFactory.registerAll(selenium); | |
| 278 | |
| 279 currentTest = new IDETestLoop(commandFactory, handler); | |
| 280 | |
| 281 currentTest.getCommandInterval = function() { return getInterval(); } | |
| 282 testCase.debugContext.reset(); | |
| 283 //debugger; | |
| 284 currentTest.start(); | |
| 285 //setState(Debugger.PLAYING); | |
| 286 } | |
| That's it for now... Episode 2 will start diving into "createSelenium", | |
| "commandFactory.registerAll", and "currentTest.start". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment