
    Xiq                     D    d Z ddlZddlmZ dZdZd Zedk(  r e        yy)zL
Argos QA - Debug why keyword input loses value / button not triggering API
    N)sync_playwrightz8/home/jay/workspace/memory/reports/task-1933-screenshotsz http://localhost:8000/dashboard/c                     t               5 } | j                  j                  d      }|j                  ddd      }|j	                         }g |j                  dfd       |j                  t        d	
       |j                  d       |j                  d      j                  }|j                          |j                  d       |j                  d      }t        d|        |j                  d      j                  }|j                          t        d       |j                  d       |j                         }t        d| d       |j                  d      }t        d|        |j                  d      }	t        d|	        t        d       |j                          |j                  d       |j                  d       |j                         }
t        d|
 d       |j!                  d       t#        j$                  d       |j                         }t        d| d       |j'                  t(         d        t        d!       |j                  d"      }t        d#| d       t#        j$                  d$       |j                         }t        d%| d       |j'                  t(         d&        |j                  d'      j                  }|j                  d(      }|j                  d)      }t        d*| d+|        |sq|j                          t#        j$                  d,       |j                  d-      j+                  d./      }t        d0|d d1         |j'                  t(         d2        nt        d3       t        d4t-               d5       d6d  D ]  }t        d7|         |j/                          d d d        y # 1 sw Y   y xY w)8NT)headlessi  i  )widthheight)viewportconsolec                 Z    j                  d| j                   d| j                         S )N[z] )appendtypetext)msgconsole_msgss    L/home/jay/workspace/memory/reports/task-1933-screenshots/03_keyword_debug.py<lambda>zrun_debug.<locals>.<lambda>   s'    |':':Qsxxj388*;U'V     domcontentloaded)
wait_untili  u%   button:has-text('네이버블로그')i  u  
            () => {
                const inp = document.querySelector('input[placeholder*="키워드를 입력하세요"]');
                if (!inp) return {found: false};
                return {
                    found: true,
                    type: inp.type,
                    value: inp.value,
                    disabled: inp.disabled,
                    readOnly: inp.readOnly,
                    parentClass: inp.parentElement?.className?.substring(0, 80),
                    reactFiber: !!inp._reactFiber || !!(inp.__reactFiber),
                    // Check if React is managing this
                    hasReactProps: Object.keys(inp).some(k => k.startsWith('__react'))
                };
            }
        zInput info: u2   input[placeholder*='키워드를 입력하세요']z
--- Method 1: .fill() ---u   실손보험zAfter fill(): value=''u  
            () => {
                const inp = document.querySelector('input[placeholder*="키워드를 입력하세요"]');
                if (!inp) return 'input not found';
                // Try to find React internal state
                const keys = Object.keys(inp);
                const reactKey = keys.find(k => k.startsWith('__reactFiber') || k.startsWith('_reactFiber'));
                if (reactKey) {
                    try {
                        let fiber = inp[reactKey];
                        while (fiber && fiber.tag !== 0) {
                            if (fiber.memoizedState && fiber.memoizedState.queue) {
                                return 'React fiber found';
                            }
                            fiber = fiber.return;
                        }
                    } catch(e) { return 'fiber error: ' + e.message; }
                }
                return 'React key: ' + (reactKey || 'none') + ', DOM value: ' + inp.value;
            }
        zReact state check: u  
            () => {
                const btns = document.querySelectorAll('button');
                for (const btn of btns) {
                    if (btn.textContent.includes('분석') && !btn.textContent.includes('경쟁')) {
                        return {
                            text: btn.textContent.trim(),
                            disabled: btn.disabled,
                            className: btn.className.substring(0, 80),
                            opacity: window.getComputedStyle(btn).opacity,
                            cursor: window.getComputedStyle(btn).cursor
                        };
                    }
                }
                return {found: false};
            }
        z
Button info before click: z'
--- Method 2: Press Enter in input --- zBefore Enter: value='Enter   zAfter Enter: value='z/03_keyword_debug_enter.png)pathz/
--- Method 3: React nativeInputValueSetter ---u  
            () => {
                const inp = document.querySelector('input[placeholder*="키워드를 입력하세요"]');
                if (!inp) return false;
                // Use React's native value setter
                const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
                    window.HTMLInputElement.prototype, 'value'
                ).set;
                nativeInputValueSetter.call(inp, '실손보험');
                inp.dispatchEvent(new Event('input', { bubbles: true }));
                inp.dispatchEvent(new Event('change', { bubbles: true }));
                return inp.value;
            }
        zAfter React setter: '   z!Input value after React setter: 'z/03_keyword_debug_react.pngu   button:has-text('분석')zel => el.disabledz)el => window.getComputedStyle(el).opacityz
Button state: disabled=z
, opacity=   bodyi  )timeoutz After button click body sample: i,  z!/03_keyword_debug_after_click.pngz7Button is disabled! Input value not recognized by Reactz
Console messages (z):iz  )r   chromiumlaunchnew_contextnew_pageongotoBASE_URLwait_for_timeoutlocatorfirstclickevaluateprintfillinput_valuepresstimesleep
screenshotSCREENSHOT_DIR
inner_textlenclose)pbrowsercontextpagetab
input_infoinpval1	react_valbtn_infoval_before_enterval_after_entersuccess	val_reactbtnbtn_disabledbtn_opacityr   mr   s                      @r   	run_debugrH      s   		 Ua**##T#2%%/M%N!	VW		('9	:d# llBCII		d# ]] $ 
" 	ZL)* llOPVV		 	+,  %dV1-. MM # 	* 	#I;/0 == " " 	,XJ78 	89		 ??,%&6%7q9:		'

1//+$_$5Q78//JKL 	@A-- !  	%gYa01

1OO%	1)A>?//JKL ll67==||$78ll#NO),z+OPIIKJJqM<<'2242@D4T$3ZLABOON#33T!UOVKL 	$S%6$7r:;cd# 	ABqc(O	 	kU U Us   N>OO__main__)__doc__r/   playwright.sync_apir   r2   r%   rH   __name__ r   r   <module>rN      s7     /K-Vp zK r   