I have a code snippet here that is functioning properly. However, I am interested in converting the Promise code in the middle of the function to Async code and replacing the for loop with map(). Can someone guide me on how to achieve this transformation?
const main = async () => {
try{
const driver = await new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
.setLoggingPrefs(prefs)
.forBrowser('chrome')
.setChromeOptions(options)
.build();
// Start promise code
await driver.findElements(By.css('input'))
.then(async (elements) => {
elements.map(async (element) => {
const val = await element.getAttribute("value");
console.log(val);
});
})
.catch((error) => {
console.log(error);
});
// End promise code
await driver.quit();
} catch (error) {
console.log(error);
}
};
main();