Browser package guide
Drive the person's Chrome or Edge through Janus, run page JavaScript, and download or check resources over HTTP.
Version 3.2.0. Installed versions can differ. Examples are illustrative and not tested. See Packages.
Prerequisites
- A Windows Device with Chrome or Edge and Mercury 4.3.0 or later.
- Janus 0.6.0 or later in the browser profile you use. Steps run in that profile, with its sign-ins. There is no separate browser and no sign-in field.
- Download file and Find broken links do not use the browser or its sign-ins.
- Capture the page with the Window picker into
$browserWindow$. A tab matches by the start of its URL (before?or#), or else by title. If more than one tab matches, the tab used last wins. - Test on your own sample site (
example.comis a stand-in), in a window you can close. JavaScript can change the page. - Fields are optional unless marked Required. A default is what the step uses when the field is empty. Numbers are whole numbers.
Shared fields
These fields mean the same in each action that has them.
| Input | Editor field | Type, default | Value |
|---|---|---|---|
window | Window | Window, empty | A captured Window, such as $browser. Empty: page actions and Close use the window this Run opened last, if still open, or else the tab used last. Open uses the tab used last. |
frame | Frame | String, empty | CSS selector of an iframe, such as iframe#preview. Empty: the page. |
timeout | Time out after (seconds) | Number, 30 | Seconds to wait for each browser call, not the whole action. 0 or less: 30, or 60 for Download file. |
browser | Browser | Browser, DEFAULT | CHROME or EDGE. DEFAULT: the browser of the tab used last, or the Windows default browser for Open. INTERNET_, FIREFOX and SAFARI are only for old steps: Open cannot start them, and other actions then match any browser. |
url | (per action) | String, empty | Required. A full URL. Open accepts https://, http:// and file://. |
file | (per action) | String, empty | A full path, or a path relative to the automation folder. Missing folders are created. |
Actions
Call a JavaScript function (browserCallJavaScriptFunction)
Call a function that the page already has, and get its return value.
Inputs
| Input | Editor field | Type, default | Value |
|---|---|---|---|
function | Function name | String, empty | Required. Such as sample.add. Only letters, digits, _, $ and .. |
function | Arguments | List, empty List | Such as $add. Strings are passed in quotes; Numbers, Booleans, Lists and Dictionaries as JavaScript values. Empty: no arguments. |
return | Return Type | Java, STRING | NONE: give an empty String. STRING, NUMBER, BOOLEAN, LIST, DICTIONARY: give the value as text. |
Also uses the shared fields window, frame and timeoutValue.
Outputs
| Output | Type | Value |
|---|---|---|
result | String | Strings stay plain. Other values become JSON text. |
Example
Run window.sample={add:(a,b)=>a+b} with Run JavaScript. Make the List $addArguments$ with Numbers 2 and 3. Set window=$browserWindow$, functionName=sample.add, functionArguments=$addArguments$, returnJavaScriptType=NUMBER. Bind result to $sumText$.
Expected result
$sumText$ is 5. If the function or iframe is not found, the step fails.
Close (browserClose)
Close a tab or its whole window.
Inputs
| Input | Editor field | Type, default | Value |
|---|---|---|---|
what | What to close | Close, Window | Tab: the tab only. Window: the window with all its tabs. |
Also uses the shared fields browser, window and timeoutValue.
Outputs
None.
Example
Set whatToClose=Tab, browser=CHROME, window=$browserWindow$.
Expected result
The tab closes; other tabs stay open. Closing the last tab also closes the window. If the tab is not found or Janus is not connected, the step fails.
Download file (browserDownloadFile)
Download a file from a URL, without the browser or its sign-ins.
Inputs
| Input | Editor field | Type, default | Value |
|---|---|---|---|
overwrite | Overwrite existing file | Boolean, false | false: fail if the file exists. true: replace it when the download is complete. |
allow | Allow an address inside the network | Boolean, false | false: refuse an address on this PC or in your private network, also after a redirect. true: allow it. |
Also uses the shared fields url (URL of file), filePath (Save to location, required) and timeoutValue (default 60).
Outputs
| Output | Type | Value |
|---|---|---|
file | Any | The downloaded file. Bind it to a File variable. |
Example
Put https://example.com/automation-samples/invoice.txt with the text Invoice sample on your server. Set url to it and filePath=samples/invoice.txt. Bind file to $downloadedFile$.
Expected result
The file contains Invoice sample. If the download fails or times out, the step fails and leaves no partial file.
Find broken links (browserFindBrokenLinks)
Check the links on a page and list the ones that do not work, without a browser.
Inputs
| Input | Editor field | Type, default | Value |
|---|---|---|---|
scope | Scope | Link, only | only: this page. whole: also linked pages on the same host, up to 50 pages. Links to other sites are checked too. Links made by page scripts are not found. |
append | Append to already existing csv file | Boolean, false | true: add rows to the CSV without a second header. Use its encoding. false: replace the CSV. |
encoding | Encoding | Csv, UTF8 | ansi: the Windows code page. UTF8: UTF-8. unicode: UTF-16, for older Windows tools. |
parallel | Number of parallel threads | Number, 8 | Links checked at the same time, 1 to 99. |
timeout | Time out (Sec) | Number, 30 | Seconds for each request. 0 or less: 30. |
allow | Allow an address inside the network | Boolean, false | false: refuse an address on this PC or in your private network, also after a redirect. true: allow it. |
Also uses the shared fields url (Page or URL) and filePath (Save list to location, empty: no CSV, only the Table).
Outputs
| Output | Type | Value |
|---|---|---|
result | Table | Broken links sorted by URL: String column url, Number column status. |
Example
Make a page https://example.com/automation-samples/links with a link that works and a link to https://example.com/automation-samples/missing, which returns 404. Set url to the page and filePath=samples/broken-links.csv. Bind result to $brokenLinks$.
Expected result
The Table has one row: the missing link with status 404. The CSV starts with url,status. A page with no broken links gives zero rows. Status 0 means not reachable; 400 or more means broken. If the first page cannot be read, the step fails.
Get source code (browserGetSourceCode)
Read the page HTML as it is now in the browser. It can differ from the file the server sent.
Inputs
Uses the shared fields window, frame and timeoutValue.
Outputs
| Output | Type | Value |
|---|---|---|
result | String | The HTML. |
Example
On a page with <p>Invoice sample</p>, set window=$browserWindow$. Bind result to $pageHtml$.
Expected result
$pageHtml$ contains the sample paragraph. If the page or iframe is not found, the step fails.
Go back (browserGoBack)
Go back in the tab's history.
Inputs
| Input | Editor field | Type, default | Value |
|---|---|---|---|
no | Number of steps back | Number, 1 | Pages to go back. 0 or less fails. |
error | Throw an error if steps exceed history | Boolean, false | true: fail if the tab cannot go back at all. |
Also uses the shared fields window and timeoutValue.
Outputs
None.
Example
In the sample tab, visit /automation-samples/first, then /automation-samples/second. Open no other window in the Run. Set window empty and errorThrownForExceedSteps=true.
Expected result
The tab is back on the first page. If there is no earlier page, the step fails. If you ask for more steps than there are pages, it goes back as far as it can and passes.
Open (browserOpen)
Open a web or file address in the person's Chrome or Edge profile.
Inputs
| Input | Editor field | Type, default | Value |
|---|---|---|---|
open | What to open | Open, NEW_ | EXISTING_: go to the URL in the matching tab. NEW_: a new tab beside it, or in the current window if window is empty. NEW_: a new window. If no tab matches, a new window opens. |
close | Close it when the run ends | Boolean, false | true: close a new window when the Run ends or stops. A Run that times out can leave it open. Tabs are not closed. |
Also uses the shared fields browser, window (only for EXISTING_TAB and NEW_TAB), url (Link to open) and timeoutValue.
Outputs
None.
Example
Set browser=CHROME, url=https://example.com/automation-samples/, closeAtEnd=true.
Expected result
A new Chrome window shows the page. Later page steps with an empty window use it. It closes when the Run ends. A bad URL, or a page that Janus cannot find, fails the step.
Run JavaScript (browserRunJavaScript)
Run JavaScript in the page, with access to the page's functions.
Inputs
| Input | Editor field | Type, default | Value |
|---|---|---|---|
script | Java | Script, SCRIPT | SCRIPT: run script. FILE: run the text of a file. |
from | File from | File, Device | For FILE. Device: a file on the Device. Room: a file in the room. |
file | Java | String, empty | For from=. A .js file relative to the automation folder, such as samples/. |
room | Java | File, empty | For from=. Pick a .js file in the room's file picker. |
script | Enter script here | String, empty | For SCRIPT. It runs like the page's own code and returns the last value, such as document.title. |
Also uses the shared fields window, frame and timeoutValue.
Outputs
| Output | Type | Value |
|---|---|---|
result | String | The value. Values that are not strings become JSON text. No value: an empty String. |
Example
On a page titled Invoice sample, set window=$browserWindow$ and script=document.title. Bind result to $pageTitle$. For a file, put document.title in samples/title.js and set scriptOption=FILE, file=samples/title.js.
Expected result
$pageTitle$ is Invoice sample. If the script or file is empty or missing, the iframe is not found, or the script fails or runs too long, the step fails.
Switch tab (browserSwitchTab)
Select a tab and bring its window to the front.
Inputs
Uses the shared fields window (required) and timeoutValue.
Outputs
None.
Example
Capture the sample page into $browserWindow$, then click another tab. Set window=$browserWindow$.
Expected result
The sample tab is selected. If no tab matches or Janus is not connected, the step fails.