The countdown is on: Register today + save your seatLearn how to leverage new AI features and observability tools, attend technical deep dives. & leave with tips for growing your observability strategy. Seats are limited and in high demand, register now!
📢 Registration + agenda now live
Explore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).
The countdown is on: Register today + save your seatLearn how to leverage new AI features and observability tools, attend technical deep dives. & leave with tips for growing your observability strategy. Seats are limited and in high demand, register now!
📢 Registration + agenda now live
Explore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).
The countdown is on: Register today + save your seatLearn how to leverage new AI features and observability tools, attend technical deep dives. & leave with tips for growing your observability strategy. Seats are limited and in high demand, register now!
📢 Registration + agenda now live
Explore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).
The countdown is on: Register today + save your seatLearn how to leverage new AI features and observability tools, attend technical deep dives. & leave with tips for growing your observability strategy. Seats are limited and in high demand, register now!
📢 Registration + agenda now live
Explore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).
The toHaveValue() method asserts that an element has a specific value. This is a retrying assertion that automatically waits for the element to have the expected value.
The toHaveValue() method checks if an element has a specific value. This is primarily used for form elements like input fields, textareas, and select elements. The method compares the element’s current value with the expected value.
This is a retrying assertion that will automatically re-check the element’s value until it matches the expected value or the timeout is reached.
Usage
JavaScript
import{ browser }from'k6/browser';import{ expect }from'https://jslib.k6.io/k6-testing/0.5.0/index.js';exportconst options ={scenarios:{ui:{executor:'shared-iterations',options:{browser:{type:'chromium',},},},}};exportdefaultasyncfunction(){const page =await browser.newPage();// Go to a test page that demonstrates input functionalityawait page.goto('https://quickpizza.grafana.com/login');// Fill input and check valueawait page.locator('#username').fill('testuser');awaitexpect(page.locator('#username')).toHaveValue('testuser');// Check textarea valueawait page.locator('#message').fill('Hello world!');awaitexpect(page.locator('#message')).toHaveValue('Hello world!');// Check select option valueawait page.locator('#country').selectOption('us');awaitexpect(page.locator('#country')).toHaveValue('us');// Check initial empty valuesawaitexpect(page.locator('#empty-field')).toHaveValue('');// Check that field doesn't have specific valueawaitexpect(page.locator('#username')).not.toHaveValue('wronguser');}