From 4a4bbd048ecd4667e8c2532b340e681c2283acef Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 30 May 2026 18:54:34 -0500 Subject: [PATCH] fix FMCSA form: wait for lvl2 dropdown, update selectors --- .../workers/services/fmcsa_web_submitter.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/workers/services/fmcsa_web_submitter.py b/scripts/workers/services/fmcsa_web_submitter.py index 9e000ee..b845229 100644 --- a/scripts/workers/services/fmcsa_web_submitter.py +++ b/scripts/workers/services/fmcsa_web_submitter.py @@ -131,9 +131,28 @@ async def submit_mcs150( # Inquiry Type — select "USDOT Number" (value=175) await page.select_option( - "#rn_ProductCategoryInputSimpleFiltered_20_Incident\\.Product_lvl1", + 'select[name="Incident.Product_lvl1"]', value="175", timeout=5000, ) + await page.wait_for_timeout(2000) + + # Sub-category — "Change/update my USDOT company information" (value=226) + # Wait for the lvl2 dropdown to appear after lvl1 selection + try: + await page.wait_for_selector( + 'select[name="Incident.Product_lvl2"]', state="visible", timeout=5000, + ) + await page.select_option( + 'select[name="Incident.Product_lvl2"]', + value="226", timeout=5000, + ) + except Exception: + # Fallback: try by partial ID match + lvl2 = await page.query_selector('select[id*="Product_lvl2"]') + if lvl2: + await lvl2.select_option(value="226") + else: + LOG.warning("[fmcsa] Could not find/select lvl2 dropdown") await page.wait_for_timeout(1000) # Question text