株式会社クリアコード > フリーソフトウェア開発 > UxU - UnitTest.XUL > How to control UxU from remote?

How to control UxU from remote? UxU - UnitTest.XUL

Command line utilities

UxX includes a server interface, like MozRepl. You can control Firefox and UxU by command line interfaces, e.g. telnet. Start UxU Server ("Tools" -> "UnitTest.XUL" -> "Test Runner" and turn on the checkbox "Server" on the bottom left of the Test Runner's window) and connect to the port 4444 (by default) of localhost, then you can run JavaScript codes directly on the UxU Server.

UxU provides some utilities for remote controlling, written in Ruby. Install ActiveScriptRuby or another Ruby runtime beforehand.

fire-test-runner

"fire-test-runner" runs any testcases in the file or the folder specified as options. Usage:

$> fire-test-runner Options "./tests"

Available options are:

-p<PORT>
--port=<PORT>
Default: "4444". He connects to the port. If connection failed, then he tries to start Fireflx and UxU Server automatically.
--firefox=<PATH TO FIREFOX OR COMMAND TO START FIREFOX>
Default: "firefox". He tries to start the specified executable or command, if connection failed.
--named-profile=<PROFILE'S NAME>
--profile=<PATH TO A PROFILE FOLDER>
Default: the default profile. If you specify an existing profile, then he starts Firefox with the profile, in "-no-remote" mode.
--wait=<SECONDS>
Default: "3". He waits 3 seconds by default, before trying to start Firefox.
--retries=<TIMES TO RETRYING>
Default: "3". He retries starting Firefox 3 times by default.
--quit
--no-quit
Default: --no-quit. "--quit" will stop and quit Firefox automatically after all tests are finished. "--no-quit" will keep Firefox running.
--close-main-windows
--no-close-main-windows
Default: --no-close-main-windows. "--close-main-windows" closes any Firefox window before starting tests. "--no-close-main-windows" keeps open them.
--use-color
--no-use-color
Default: auto. "--use-color" colorizes the result of tests. In the mode, successed tests are green, failed tests are red, and errors in specified tests are yellow. By default, he automatically colorize results if the platform can do it.

ifx - Interactive Firefox Shell

"ifx" is a shell program, which can connect to running UxU Server. Start UxU Server ("Tools" -> "UnitTest.XUL" -> "UxU Server") and run ifx, then an prompt "firefox>" will appear. Typed strings are evaluated as JavaScript codes.

JavaScript codes are run in the window of UxU Server itself. For example, if you type alert("Hello!"), then the alert dialog appears on the UxU Server window. location.href will return "chrome://uxu/content/ui/uxu.xul".

UxU is designed for automated test, so, there are less utilities for remote-controlling. If you wish to control Firefox from remote processes flexibly, try MozRepl.

Helper methods

In the execution context while connecting from ifx, telnet or others, following helper methods (functions) are available, moreover action helpers, file I/O helpers, and string operation helpers too.

Explanatory Note

<type of the returned value> <method name>(<argument>, [<optional argument>])
<descriptions.>

List of helper methods

String inspect(in Object aObject)
Returns inspected result of the specified object.
Array
A list of inspect()ed result of each element will be returned.
Object (object literals, hashes, instances of custom classes)
A list of inspect()ed result of each property will be returned.
String inspectDOMNode(in DOMNode aNode)
Returns XML source code of specified DOM node.
void puts(in Object aObject)
void print(in Object aObject)
Dumps toString()ed results of the specified objects. If you hand multiple objects to them, then puts() dumps results in lines, print() dumps results in just one line.
void p(in Object aObject)
Dumps inspect()ed strings of specified objects. If you hand multiple objects, then results are shown in multi-lines.
void error(in Exception aException)
Dumps detailed information of the exception object.
void load(in String aURI[, in Object aContext])
Loads and runs the JavaScript file specified by an URI string. The script will be run in the specified context or the current context.
void quit()
void exit()
Disconnects from UxU Server. Even if you disconnect, UxU Server and Firefox stay running.
void quitApplication(in Boolean aForceQuit)
Quits Firefox and disconnects. If you don't want confirmation dialog for each window, specify true.
void closeMainWindows()
Closes all of Firefox windows.
void runTest()