direction (string) - Scroll direction (default: 'down')
maxDistance (number) - Max pixels to scroll (default: 10000)
textMatchMethod (string) - 'turbo' or 'ai' (default: 'turbo')
method (string) - 'keyboard' or 'mouse' (default: 'keyboard')
invert (boolean) - Scroll until text disappears (default: false)
Examples:
Copy
// Scroll down until "Contact Us" appearsawait testdriver.scrollUntilText('Contact Us');// Scroll up to find textawait testdriver.scrollUntilText('Header', 'up');// Scroll until text disappearsawait testdriver.scrollUntilText('Loading...', 'down', 5000, 'turbo', 'keyboard', true);// Use AI matching for fuzzy textawait testdriver.scrollUntilText('footer content', 'down', 10000, 'ai');
// For web pages, mouse scroll is usually smootherawait testdriver.scroll('down', 300, 'mouse');// For desktop apps or when mouse doesn't workawait testdriver.scroll('down', 300, 'keyboard');
Use scrollUntil for dynamic content
Copy
// Instead of guessing scroll amountawait testdriver.scrollUntilText('Load More button');const loadMoreBtn = await testdriver.find('Load More button');await loadMoreBtn.click();
Set reasonable max distance
Copy
// Avoid infinite scrollingawait testdriver.scrollUntilText('Footer', 'down', 5000); // Max 5000px
Keyboard scroll uses Page Down/UpKeyboard scrolling typically moves by one “page” at a time, which may be more than the specified pixel amount. It’s more compatible but less precise than mouse scrolling.
// Scroll to load more buttonawait testdriver.scrollUntilText('Load More');const loadBtn = await testdriver.find('Load More button');await loadBtn.click();await new Promise(r => setTimeout(r, 2000));
Find Element in Long List
Copy
// Scroll through list to find itemawait testdriver.scrollUntilText('Product #42');const product = await testdriver.find('Product #42');await product.click();
Infinite Scroll
Copy
// Scroll multiple times for infinite scrollfor (let i = 0; i < 5; i++) { await testdriver.scroll('down', 500); await new Promise(r => setTimeout(r, 1000)); // Wait for load}
Horizontal Gallery
Copy
// Navigate horizontal carouselawait testdriver.scroll('right', 300);await new Promise(r => setTimeout(r, 500));const nextImage = await testdriver.find('next image in carousel');await nextImage.click();