I need help with Puppeteer JS to select the initial element in a dropdown. Any suggestions?
Once I input the city name in the text field, I want to choose the first option from the dropdown menu.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
const page1=await page.goto('https://www.srinu.com');
await page.screenshot({path: 'example.png'});
const date = '#SearchBoxContainer > div > div > div.IconBox.IconBox--autocomplete > div > div > input';
await page.click(date);
await page.type(date, 'China');
await page.select('#data-text', 'Chinatown')
// const option = (await page.$x(
// '//*[@id="SearchBoxContainer"]/div/div/div[5]/div/div/ul/li[1]'
// ))[0].click();
Both the click and select methods have been attempted but didn't work as expected.