fix(sync): use ViewState extraction for Untersuchungen pagination instead of form submit

This commit is contained in:
Matthias Hochmeister
2026-04-19 19:37:17 +02:00
parent b401b75b9a
commit 3b4a14661c

View File

@@ -979,15 +979,23 @@ async function scrapeMemberUntersuchungen(
return [];
}
// Show all rows: select "ALLE", then explicitly submit the form so ASP.NET
// processes the request with its server-generated ViewState.
await selectAlleAnzeige(frame);
const submitBtn = frame.locator('input[type="image"][src*="suchen"]');
if (await submitBtn.count() > 0) {
await Promise.all([
frame.waitForNavigation({ waitUntil: 'networkidle', timeout: 15000 }).catch(() => {}),
submitBtn.click(),
]);
// ASP.NET needs ViewState to properly process anzeige_count.
// Extract it from the loaded page and re-navigate with all params + ALLE.
const formState = await frame.evaluate(() => {
const vs = (document.getElementById('__VIEWSTATE') as HTMLInputElement)?.value ?? '';
const vsg = (document.getElementById('__VIEWSTATEGENERATOR') as HTMLInputElement)?.value ?? '';
return { vs, vsg };
}).catch(() => ({ vs: '', vsg: '' }));
if (formState.vs) {
const alleUrl = `${BASE_URL}/fdisk/module/mgvw/untersuchungen/UntersuchungenList.aspx`
+ `?__VIEWSTATE=${encodeURIComponent(formState.vs)}`
+ `&__VIEWSTATEGENERATOR=${encodeURIComponent(formState.vsg)}`
+ `&searchdatum=&searchanmerkungen=&searchid_untersuchungsarten=`
+ `&searchid_personen=${idPersonen}&searchid_mitgliedschaften=${idMitgliedschaft}`
+ `&id_personen=${idPersonen}&id_mitgliedschaften=${idMitgliedschaft}`
+ `&anzeige_count=ALLE&offset=0&ordnung=2&orderType=ASC&search=1`;
await frame_goto(frame, alleUrl);
}
// Try to navigate to history/detail view if available