@@ -741,6 +741,7 @@ export class HybridBrowserSession {
741741 }
742742 } else {
743743 // Try to fill the element, with fallback to click-then-fill strategy
744+ let alreadyClicked = false ;
744745 try {
745746 let fillSuccess = false ;
746747
@@ -754,6 +755,7 @@ export class HybridBrowserSession {
754755 console . log ( `Direct fill failed for ref=${ ref } , trying click-then-fill strategy` ) ;
755756 try {
756757 await element . click ( { force : true } ) ;
758+ alreadyClicked = true ;
757759 console . log ( `Clicked element ref=${ ref } before typing` ) ;
758760 } catch ( clickError ) {
759761 console . log ( `Warning: Failed to click element before typing: ${ clickError } ` ) ;
@@ -786,26 +788,31 @@ export class HybridBrowserSession {
786788 } catch ( fillError : any ) {
787789 // Log the error for debugging
788790 console . log ( `Fill error for ref ${ ref } : ${ fillError . message } ` ) ;
789-
791+
790792 // Check for various error messages that indicate the element is not fillable
791793 const errorMessage = fillError . message . toLowerCase ( ) ;
792- if ( errorMessage . includes ( 'not an <input>' ) ||
794+ if ( errorMessage . includes ( 'not an <input>' ) ||
793795 errorMessage . includes ( 'not have a role allowing' ) ||
794796 errorMessage . includes ( 'element is not' ) ||
795797 errorMessage . includes ( 'cannot type' ) ||
796798 errorMessage . includes ( 'readonly' ) ||
797799 errorMessage . includes ( 'not editable' ) ||
798800 errorMessage . includes ( 'timeout' ) ||
799801 errorMessage . includes ( 'timeouterror' ) ) {
800-
801- // Click the element again to trigger dynamic content (like date pickers)
802- try {
803- await element . click ( { force : true } ) ;
804- console . log ( `Clicked element ref=${ ref } again to trigger dynamic content` ) ;
805- // Wait for potential dynamic content to appear
802+
803+ // Click the element again to trigger dynamic content (like date pickers), but only if we haven't clicked yet
804+ if ( ! alreadyClicked ) {
805+ try {
806+ await element . click ( { force : true } ) ;
807+ console . log ( `Clicked element ref=${ ref } to trigger dynamic content` ) ;
808+ // Wait for potential dynamic content to appear
809+ await page . waitForTimeout ( 500 ) ;
810+ } catch ( clickError ) {
811+ console . log ( `Warning: Failed to click element to trigger dynamic content: ${ clickError } ` ) ;
812+ }
813+ } else {
814+ // We already clicked during the click-then-fill strategy
806815 await page . waitForTimeout ( 500 ) ;
807- } catch ( clickError ) {
808- console . log ( `Warning: Failed to click element to trigger dynamic content: ${ clickError } ` ) ;
809816 }
810817
811818 // Step 1: Try to find input elements within the clicked element
0 commit comments