A page object spawned in by using the newPage()
method can be used to navigate a page. The click()
method clicks on the specified element on the page.
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('https://www.example.org')
await page.click('a')
await waitFor(3000)
await page.saveSnapshot('clicked-page')
await page.close()
// -- END --
end()
} catch(e) { except(e) } })();
The given snippet:
newPage()
a
. In this case, this will be the only hyperlink in the page.NOTE: Click method throws an error if the specified selector has more than one matching element on the page.
NOTE: There is a guided counterpart for the click method called clickTag where the latter requires a scraper configured.