FANDOM


SelBench 1.1Edit

Installer: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-selbench/

DescriptionEdit

Provides utilities for testing, validating, and benchmarking Selenium IDE scripts. This is especially useful for instrumenting scripts that are used to test Selenium IDE extensions.

FeaturesEdit

  • Convenience functions: $w() and $d() are shorthand references to the window and document objects of the target webpage
  • Commands:
   alert, log, clearLog,
   deleteVars,
   expectError, emit, assertEmitted, resetEmitted,
   startTimer, timerElapsed

Examples of UseEdit

Object access:

assertEval|$d().title === $w().document.title

Simple logging and prompting:

alert|"hello world"
log|"hello world"
clearLog

Undefining Selenium variables:

deleteVars|a,b,c

Verifying that a command will fail as expected:

expectError|"n is not define"
getEval|n

Tracking state and sequence,("$" + "{n}~" prevents Selenium variable substitution):

resetEmitted
deleteVar|n
emit|"${n}"
store|0|n
emit|n++
emit|"${n}"
assertEmitted|"$" + "{n}~" + 0 + "~" + 1

Timing script execution:

startTimer
timerElapsed

$w() and $d() can be used in expressions:

assertEval|$d().title === $w().document.title|true

Selenium ServerEdit

Sorry, this feature has a significant bug, and is not currently supported.

Selenese scripts that use SelBench commands can also be run in Selenium Server via the -user-extensions and -htmlSuite options. Get the current user-extensions.js here: https://raw.githubusercontent.com/refactoror/SelBench/master/user-extensions.js

For more information on running Selenium Server, see: http://www.seleniumhq.org/docs/08_user_extensions.jsp#using-user-extensions-with-selenium-ide

Note that prior to version 1.1 SelBench has been a Firefox extension only, whereas Selenium Server can target a wide range of browsers. SelBench currently passes its full regression test suite when run against:

  • firefox (31.4)
  • googlechrome (40.0)
  • opera (27.0)

Community help is welcome and encouraged in expanding this list. There are currently known issues with:

  • iexplorer (11.0): Object.defineProperties fails - test-startup hangs
  • safari (5.1.7): htmlTestRunner is not defined - test-startup hangs

Running scripts in Selenium Server introduces the possibilty of browser compatibility issues, especially when running IDE-produced scripts against non-Firefox browsers. Potential pain points include differences in JavaScript error messaging, (e.g., try/catch), and DOM property values, (e.g., $w().title).

When reporting an issue, be sure to provide very specific browser/OS info, as well as the faling test case, test html, and error log. Better yet, if you can fix the problem, submit a github pull request -- which is how server support came about in the first place. A big thanks to Matthew Kastor for this contribution!

For an overview of how the SelBench user extension works, see: https://github.com/refactoror/SelBench/blob/master/notes/SeleniumServer-notes.txt

Function ReferenceEdit

Function Description
$w() Shorthand reference to the browser window object.
$d() Shorthand reference to the browser document object.

Command ReferenceEdit

Command Target Value Description
alert message Display the evaluated JavaScript expression as a browser alert message.
log message ?log-level Write the evaluated JavaScript expression to the IDE log.
clearLog Clear the IDE log window.
deleteVars comma-separated-vairable-names Remove the named Selenium variable(s).
expectError regular-expression or substring Verify that the next command in the script fails with the specified error.
emit string Append the evaluated JavaScript expression to the current emitted state. A ~ is inserted between each append.
assertEmitted expected-value(s) Verify that the accumulated emit state matches the given value.

If an array of values is specified, then matches for a ~ between each element

resetEmitted Clear the accumulated emitted state.
startTimer timer-name ?description Start a stopwatch-like timer.
timerElapsed timer-name ?script Report the current elapsed time as a log message.

LimitationsEdit

The expectError command operates on the next command to be executed. But it cannot be used on:

  • Commands that cannot fail, (e.g., startTimer, the SelBlocks exitTest command)
  • Commands that themselves manage other commands, (e.g., itself, the SelBlocks try command)

Never use the ...AndWait counterpart of a SelBench command, e.g., logAndWait. (Selenium automatically registers one with every defined command, even though it does not always make sense.) If you use one of these, (usually via inadvertent auto-completion), SelBench will throw an error when you try to start the script in the IDE.

This is a bit more difficult to diagnose in Selenium Server, which cannot currently detect the situation, and therefore simply hangs without an error when such a command executes.

TroubleshootingEdit

Selenium ServerEdit

Testsuite works in the IDE, but won't start in ServerEdit

  • You haven't provided the SelBench user-extensions.js on the command line.

Test hangs at SelBench commandEdit

  • You may have used the AndWait counterpart command. This is never valid because SelBench commands do not interact with webpages.

Revision HistoryEdit

  • 2015-02-12: v1.1
    • Added support for Selenium Server. (A big thanks to Matthew Kastor for this contribution)
    • Added clearLog command.
    • Added deleteVars command, (deprecated deleteVar).
    • Fixed Issue #4 expectError fails on unexpected error
    • Fixed Issue #5 expectError not clearing script error status
  • 2013-03-07: v1.0

All versions: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-selbench/versions/

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.