How to check a value on a page

How to verify a value from the response page.

Example.
I want to verify the text Logout from the page using the k6 check option on the HTTP protocol level. Any options to do a similar check on k6 Browser automation?

Hi @gerardlj,

Would this example from the docs help?

import { chromium } from 'k6/experimental/browser';
import { check } from 'k6';

export default async function () {
  const browser = chromium.launch({ headless: false });
  const page = browser.newPage();

  try {
    await page.goto('https://test.k6.io/my_messages.php');

    page.locator('input[name="login"]').type('admin');
    page.locator('input[name="password"]').type('123');

    const submitButton = page.locator('input[type="submit"]');

    await Promise.all([page.waitForNavigation(), submitButton.click()]);

    check(page, {
      header: page.locator('h2').textContent() == 'Welcome, admin!',
    });
  } finally {
    page.close();
    browser.close();
  }
}

You can use page locator to check if the expected logout text is in the page.

I hope this helps :bowing_woman: Let us know if otherwise.

Cheers!