Test pull down refresh
Users pull down from the top of a scrollable list to trigger a refresh. The gesture should have visual feedback (pull indicator) and a threshold distance before activating.
Pull down to refresh
↓ Pull down from the top to refresh
Item 1
—
Item 2
—
Item 3
—
Events and progress
Pull down to see events
0% of threshold
Automation hints
// Pull-to-refresh simulation
const container = page.getByTestId('pull-refresh-container');
const box = await container.boundingBox();
// Start at top of container
const startX = box.x + box.width / 2;
const startY = box.y + 10;
// Swipe down past threshold
await page.mouse.move(startX, startY);
await page.mouse.down();
await page.mouse.move(startX, startY + 100, { steps: 20 });
await page.mouse.up();
// Wait for refresh to complete
await expect(page.getByText('Refreshing...')).toBeVisible();
await expect(page.getByText('Refreshing...')).not.toBeVisible();
// Verify new item was added
const items = page.getByTestId('items-list').locator('> div');
const count = await items.count();
expect(count).toBe(4); // Was 3, now 4
// Alternative: Use touchscreen API
await page.touchscreen.tap(startX, startY);
// Note: touchscreen doesn't support drag directly
// Use page.mouse with hasTouch: true context// Pull to refresh with Appium
WebElement list = driver.findElement(By.id("pull-refresh-container"));
// Get coordinates
int centerX = list.getLocation().getX() + list.getSize().width / 2;
int startY = list.getLocation().getY() + 50;
int endY = startY + 200; // Pull down 200px
// W3C Actions for swipe
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence pullDown = new Sequence(finger, 0);
pullDown.addAction(finger.createPointerMove(
Duration.ZERO, Origin.viewport(), centerX, startY));
pullDown.addAction(finger.createPointerDown(MouseButton.LEFT.asArg()));
pullDown.addAction(finger.createPointerMove(
Duration.ofMillis(500), Origin.viewport(), centerX, endY));
pullDown.addAction(finger.createPointerUp(MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(pullDown));
// Wait for refresh indicator
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(
By.xpath("//*[contains(text(), 'Refreshing')]")));
wait.until(ExpectedConditions.invisibilityOfElementLocated(
By.xpath("//*[contains(text(), 'Refreshing')]")));
// Verify new content loaded
List<WebElement> items = driver.findElements(By.cssSelector("[data-testid^='item-']"));
assertEquals(4, items.size());