Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
WebDriverIO (JavaScript) - Object key-value pair is not iterating as expected

I have an array of objects 'arr'. each value should be looped through forEach loop and key (which is a parentEle) should be clicked first and the value (which is a childEle) should be clicked next. like wise the loop should repeat 5 times. where as it is looping all the five elements at a time and then clicking on the first parentEle1 and then exiting the loop. Tried lot of ways but no luck. highly appreciate any resolution on this.

static changeCoverage = async function (testData) {
var onlyCoverage = _.drop(testData[0].coverage);
onlyCoverage.forEach(async (coverages) => {
  var filteredCoverage = _.omit(coverages, ["coverageType"]);
  Object.entries(filteredCoverage).forEach(async ([key, value]) => {
    var isKeyDisplayed = await $(`//div[text()="${key}"]`).isDisplayed()
    logger.info(
      "INFO",
      "availability of coverage key we are changing is: " + isKeyDisplayed
    );
    await coveragesPM.clickAndWait($(`//div[text()="${key}"]`))

    var isValueDisplayed = await $(`//div[text()="${key}"]/../../../../../..//span[text()="${value}"]`).isDisplayed()
    logger.info(
      "INFO",
      "availability of coverage value we are changing is: " + isValueDisplayed
    );
    await coveragesPM.clickAndWait($(`//div[text()="${key}"]/../../../../../..//span[text()="${value}"]`))
  });
});

}

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!