How to use Input and Output in Scripts

Scripts provide a variety of ways to handle inputs and output. The input to scripts are handled in the script. This is done by using the provided keyboard and mouse objects. The input to required elements as well as the element selection is to be specified while designing the script. The script outputs are at three levels. Normal Logs can be created using console.log. Warning messages are created using console.warn. Error messages are created using console.error .

Example Script:

let {newPage, end, except, extract, extractAndSave, store, runStore, waitFor} = __sandbox;
let {params, } = OPTIONS;
(async () => { try {
	// -- START --


	const page = await newPage()
	await page.goto('')
	await page.keyboard.type('Random stuff typed in a text bin')
	await waitFor(10000)
	await page.saveSnapshot('text-bin')
	await page.close()

	console.log('this is a log')
	console.warn('this is a warning')
	console.error('this is an error')

	// -- END --
} catch(e) { except(e) } })(); IO Script

Downloadable IO Project

Code Breakdown

The given snippet:

  • Opens a new page object using newPage()
  • Navigates to the the url
  • Click the element denoted by #message which is the message box in the page
  • Type in Random stuff typed in a text bin into the clicked element
  • Click the element #sendbutton which is the button to submit form
  • Wait for 10s to navigate
  • Saves a page snapshot for the user to observe after execution
  • Make a log this is a log
  • Make a warning this is a warning
  • Make an error this is an error
  • close the page.

NOTE: There are more than one ways to enter text in to a page. Same goes for clicks.

NOTE: There is currently no way to use input to scripts at the runtime