|
|
|
|
|
by leandot
852 days ago
|
|
Are you looking for a web service that does the whole thing? Otherwise asking ChatGPT gives you convert this free text I goto to example.com
I click the search bar
I type in “fruit”
Expect to see a list of fruit
to playwright scriptconst { chromium } = require('playwright'); (async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage(); // Navigate to example.com
await page.goto('https://example.com');
// Click the search bar
await page.click('input[type="search"]');
// Type in "fruit"
await page.type('input[type="search"]', 'fruit');
// Press Enter to submit the search
await page.press('input[type="search"]', 'Enter');
// Wait for the page to load
await page.waitForLoadState('networkidle');
// Expect to see a list of fruit
const fruitList = await page.$$('ul li');
if (fruitList.length > 0) {
console.log('List of fruit found!');
} else {
console.error('Failed to find the list of fruit.');
}
// Close the browser
await browser.close();
})(); |
|