You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am trying to print a list of element text. It works when I for, but if I do the same in foreach, map, or filter it's not working.
Kindly let me know what am doing wrong here.
Sample code:
awaitpage.goto("https://letcode.in/elements");awaitpage.fill("input[name='username']","ortonikc");awaitpage.press("input[name='username']","Enter");awaitpage.waitForSelector("app-gitrepos ol li",{timeout: 5000});constrepos=awaitpage.$$("app-gitrepos ol li");console.log(repos.length);// this worksforawait(constrepoofrepos){console.log(awaitrepo.innerText());}// This is not workingrepos.map(async(ele,i)=>{consttext=awaitele.innerText();console.log(text);})
The text was updated successfully, but these errors were encountered:
ortoniKC
changed the title
[Question] How to use map functions in $$
[Question] How to use map function in $$
May 6, 2021
@ortoniKC when you pass an async function to the repos.map, the result would be a Promise. So you'll probably need to await all promises. For example, to get an array of inner texts:
Hi, I am trying to print a list of element text. It works when I for, but if I do the same in foreach, map, or filter it's not working.
Kindly let me know what am doing wrong here.
Sample code:
The text was updated successfully, but these errors were encountered: