update
This commit is contained in:
@@ -146,9 +146,10 @@ async function scrapeMembers(frame: Frame): Promise<FdiskMember[]> {
|
||||
if (hasForm) {
|
||||
const fieldDump = await frame.evaluate(() => {
|
||||
const form = (document as any).forms['frmsearch'];
|
||||
if (!form) return { cleared: [], allFields: [] };
|
||||
if (!form) return { cleared: [], pageSizeSet: null as string | null, allFields: [] };
|
||||
const cleared: string[] = [];
|
||||
const allFields: string[] = [];
|
||||
let pageSizeSet: string | null = null;
|
||||
for (const el of Array.from(form.elements) as HTMLInputElement[]) {
|
||||
if (el.type === 'hidden') continue;
|
||||
const name = (el.name ?? '').toLowerCase();
|
||||
@@ -158,8 +159,29 @@ async function scrapeMembers(frame: Frame): Promise<FdiskMember[]> {
|
||||
el.value = '';
|
||||
cleared.push(el.name || el.id);
|
||||
}
|
||||
// Maximize page size: look for a select that controls rows per page
|
||||
if ((name.includes('anzahl') || id.includes('anzahl') ||
|
||||
name.includes('pagesize') || id.includes('pagesize') ||
|
||||
name.includes('rows') || id.includes('rows')) &&
|
||||
el.tagName === 'SELECT') {
|
||||
const select = el as unknown as HTMLSelectElement;
|
||||
// Pick the largest numeric option value, or the last option as fallback
|
||||
let bestOption: HTMLOptionElement | null = null;
|
||||
let bestVal = -1;
|
||||
for (const opt of Array.from(select.options)) {
|
||||
const n = parseInt(opt.value, 10);
|
||||
if (!isNaN(n) && n > bestVal) { bestVal = n; bestOption = opt; }
|
||||
}
|
||||
return { cleared, allFields };
|
||||
if (!bestOption && select.options.length > 0) {
|
||||
bestOption = select.options[select.options.length - 1];
|
||||
}
|
||||
if (bestOption) {
|
||||
select.value = bestOption.value;
|
||||
pageSizeSet = `${el.name || el.id}=${bestOption.value}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
return { cleared, pageSizeSet, allFields };
|
||||
});
|
||||
if (fieldDump.allFields.length > 0) {
|
||||
log(`Search form active filters before clear: ${fieldDump.allFields.join(', ')}`);
|
||||
@@ -169,6 +191,11 @@ async function scrapeMembers(frame: Frame): Promise<FdiskMember[]> {
|
||||
} else {
|
||||
log('Search form found — no Standesbuchnummer field detected, submitting as-is');
|
||||
}
|
||||
if (fieldDump.pageSizeSet) {
|
||||
log(`Set page size: ${fieldDump.pageSizeSet}`);
|
||||
} else {
|
||||
log('No page size field found — result may be paginated');
|
||||
}
|
||||
// Use Promise.all to start waiting for navigation BEFORE triggering the submit,
|
||||
// otherwise waitForLoadState resolves against the already-idle current page.
|
||||
await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user