Skip to main content

Run JavaScript

Run JavaScript in the page and return its result: an expression such as document.title, or statements with return.

Command in the Browser toolkit · id ooa.browser/run_javascript · 6 inputs, 1 output

Inputs​

InputTypeRequiredDefaultWhat it is
ScriptStringNoJavaScript typed here: an expression, a function, or statements that end with return.
SessionStringNobrowserSession name.
Script fileFileNoOr a .js file to run (UTF-8), used instead of the typed script.
WindowDictionaryNoWhich window to act in. Leave empty to use the session's current tab. {"source": "browser", "title": "Invoice * - Shop", "title_match": "wildcard", "url": "...", "url_match": "contains", "browser": "edge"} switches to the first open tab whose title and/or address matches (also in attached browsers, and in one listening on port 9222); {"source": "variable", "variable": "session name"} uses that browser session; {"source": "application", "title": "..."} names a desktop window, which works only when it is a window of an attached browser. Matches: wildcard (default for the title), contains (default for the address), equals or regex; text matches ignore case. Values may use variables.
FrameDictionaryNoRun the script inside this iframe instead of the main page: the captured iframe element.
Wait up to (milliseconds)NumberNo60000How long to wait for the browser to answer (G4).

Outputs​

OutputTypeWhat it is
resultAnyValue returned by the script.