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

190
Views
How to convert table data to array by using selenium+Javascript

I want to get HTML table data to cover to array by using selenium and Javascript. I test below code and I can get console.log(lm) in the for loop, but it shows array each loop.

the wepage is https://www.scoresandodds.com/mlb and click Game Details-->Line Movement

How I can get array(lm) at the end of the code? why I can not get any data in my code ?

    console.log("Line Movement=================================\n");
driver.findElement(By.xpath('//*[@id="line-movements-tab--65040"]/span')).click(); //Line Movement
await driver.sleep(2500);

let rowC = '';
driver.findElements(By.xpath('//*[@id="line-movements--65040"]/div/table/tbody/tr')).then( function(rows){
        console.log("[" + rows.length + "]" + "\n\n");
        rowC = rows.length;
});

var lm=[];
for (i=0; i<rowC; i++) {
            for (s=1; s<5; s++) {
                var addCellText=function(elem, doneCallback){
                             elem.getText().then(function(textValue){
                                     driver.sleep(1000);
                                     lm.push(textValue);
                                     return doneCallback(null);
                             });
                 };
                 xpath='//*[@id="line-movements--65040"]/div/table/tbody/tr[' + i + ']/td[' + s + ']';
                 driver.findElements(By.xpath(xpath)).then(function(elem){
                       async.each(elem, addCellText, function(error){
                                     driver.sleep(1000);
                                    //console.log(lm);
                       });
                   });
           }
}
console.log("lm");
console.log(lm);

each team has a different code such as 65040, please look at each games code in the html. For example today(5/30) ARI-ATL of the code is 65051.

about 4 years ago · Juan Pablo Isaza
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!