title | layout |
---|---|
(Automated reloading of custom Selenium Core) |
default |
{% include links %}
- TOC {:toc}
SeLite Bootstrap (Components > Bootstrap) allows smoother development of Selenium [Core extensions][Core extension] (just in plain Javascript files, not packaged as .xpi
). It reloads them automatically on change.
It's more convenient than Selenium IDE's way of loading [Core extensions][core extension] (Selenium menu > Options > Options > General > Activate developer tools), which requires you to apply Selenium menu > Options > Options > General > Reload button every time you change your extension file.
It adds field bootstrapCoreExtensions
to Settings module extensions.selite-settings.common
, where you can choose file(s) containing your [Core extension] in Javascript (saved in UTF-8). Configure that through {{valuesManifest}} with {{navLiteralsForSpecialValues}} > SELITE_THIS_MANIFEST_FOLDER
. That makes your [scripts][script] shareable.
If you modify any one file that is registered with Bootstrap (while using Selenium IDE), all the registered files get re-loaded automatically
- before you run a single Selenese [command],
- before you run a [case]/[suite] or
- after you pause a currently case/suite run and before you subsequently resume it,
- but not during an active case/suite run that started before you changed the file(s).
Apply JavascriptEssential, especially sections Strict Javascript and Prevent name conflicts.
It works only in standalone Selenium IDE, but not in auxiliary Selenium IDEs inside browser (neither in Selenium IDE in browser sidebar).
Bootstrap reloads all registered extensions (whenever you modify any one of them). You can 'extend' existing Javascript functions as per {{navFunctionIntercepts}}. However, don't re-save and re-extend the current function each time the Javascript is run. Otherwise it would increase the intercept chain every time Bootstrap reloads it. Instead, save the original function on the first load only, but re-extend it on every load. For example:
var originalMethod;
if( originalMethod===undefined ) {
originalMethod= Selenium.prototype.methodName;
}
Selenium.prototype.methodName= function(pqr...) {
originalMethod.call(this);
// extra new tasks...
};
See also {{navFunctionIntercepts}}.
If you introduce or modify any Selenese [commands][command] - i.e. Selenium.prototype.doXyz, Selenium.prototype.getXyz
or Selenium.prototype.isXyz
- then those will be available to your [case]/[suite] only after you run any Selenese command first.
If you remove a filename from bootstrapCoreExtensions
(or you switch to a different default [set] or a [suite] with a different [set] associated with it), Bootstrap can't 'unload' a file that it has loaded already. If you change that option later and you add the filename back, it won't re-run the file, unless its timestamp has changed.
Bootstrap initiates extensions after any [Core extensions][core extension] loaded as Firefox add-ons (whether they use [Extension Sequencer] or not).
If you have multiple files registered with Bootstrap through a {{valuesManifest}}, they get loaded in that order. However, if you register multiple files through profile-based configuration (as per SettingsInterface), their order is not guaranteed. Then you need more structure for that: package them as Firefox extensions and load them through [Extension Sequencer].
On change, Bootstrap re-loads all registered files, not just the one(s) updated. That allows dependant files (that were registered with Bootstrap through a {{valuesManifest}}) to inject any hooks in the expected order.