PuppeteerSharp evaluate expression to complex type?

PBMe_HikeIt :

Hi I am using PuppeteerSharp for the first time and am wondering if EvaulateExpressionAsync supports a way to convert to a complex c# object. So when i try to do something like this:

var allResultsSelector = ".sortableTable.resultTable tr.studyResultRow";

var jsSelectAllAnchors = $"Array.from(document.querySelectorAll('{allResultsSelector}')).map(f=>f.innerText);";

await frmSearch.WaitForSelectorAsync(allResultsSelector);

var urls = await frmSearch.EvaluateExpressionAsync<InteleStudyResult[]>(jsSelectAllAnchors);

c# type for now

    public class InteleStudyResult
    {
        public string PatientName { get; set; }
        //public string PatientId { get; set; }
        //public DateTime DOB { get; set; }
        //public string Sex { get; set; }
        //public string Accession { get; set; }
        //public DateTime StudyDate { get; set; }
        //public string Modality { get; set; }
        //public int? Series { get; set; }
        //public string StudyDescription { get; set; }
    }

exception occurs on the Eval call

Newtonsoft.Json.JsonSerializationException HResult=0x80131500 Message=Error converting value " my string here " to type 'InteleradWebAccessor.InteleStudyResult'. Path '[0]'. Source=Newtonsoft.Json

Inner Exception 1: ArgumentException: Could not cast or convert from System.String to InteleradWebAccessor.InteleStudyResult.

If this is not supported I'd greatly appreciate a suggestion on best way to handle getting what is a html table row into a c# complex type using PuppeteerSharp

hardkoded :

You should an object in your map

Array.from(document.querySelectorAll('{allResultsSelector}'))
   .map(f =>{ return { patientName: f.innerText} });

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=383256&siteId=1