Skip to main content
The Page class is where most of your Uplink automation happens. It provides methods for navigation, element interaction, JavaScript execution, and more.

Getting started

Create a page from a browser instance:
const browser = await client.launch()
const page = await browser.newPage()

await page.goto('https://example.com')
await page.click('#button')

API categories

The Page API is organized into several categories:

Navigation

Navigate to URLs and track page loading

Interaction

Click elements, type input, and interact with the page

JavaScript

Execute JavaScript and inject user scripts

Waiting

Wait for elements, functions, and network requests

Authentication

Handle authentication flows

Cookies

Manage browser cookies

HTTP Requests

Make HTTP requests via the device

Screenshots

Capture screenshots of the page

Events

Listen to page events and lifecycle

Common workflows

User authentication + automation

// User logs in on their device
await page.goto('https://example.com/login')
await page.waitForAuthentication(
  async (page) => {
    const url = await page.url()
    return url.includes('/dashboard')
  },
  { timeout: 120000 }
)

// Now automate authenticated actions
await page.click('#export-data')
await page.waitForSelector('.download-ready')

Data extraction

await page.goto('https://example.com/products')

const products = await page.evaluate(() => {
  return Array.from(document.querySelectorAll('.product')).map(el => ({
    name: el.querySelector('.name').textContent,
    price: el.querySelector('.price').textContent
  }))
})

console.log('Found products:', products)

Network monitoring

const controller = await page.on('xhr', async (event) => {
  const req = event.data
  console.log('Request:', req.method, req.url)

  if (req.response) {
    console.log('Response:', req.response.status)
  }
})

await page.goto('https://example.com')

// Stop monitoring
await page.off(controller)

Lifecycle

Creating pages

const browser = await client.launch()
const page = await browser.newPage()

Closing pages

await page.close()
Always close pages when done to free up device resources.

UI visibility

Pages can be shown or hidden without closing them:
await page.show()  // Bring to foreground
await page.hide()  // Send to background

Best practices

Always wait for elements to appear before interacting with them:
await page.waitForSelector('#button')
await page.click('#button')
Set appropriate timeouts for navigation and operations:
// 60 second timeout for slow pages
await page.goto('https://slow-site.com', {}, 60000)
Remove event listeners when done to prevent memory leaks:
const controller = await page.on('xhr', handler)

// When done
await page.off(controller)
Access DOM content using evaluate() rather than trying to parse HTML:
const title = await page.evaluate(() => document.title)

Next steps

Explore each category of the Page API:

Navigation

page.goto(), page.url(), page.progress()

Interaction

page.click(), page.input(), page.select()

JavaScript

page.evaluate(), page.addUserScript()

Waiting

page.waitForSelector(), page.waitForFunction()