@@ -142,19 +142,32 @@ class UIWorkflowTest {
142142 */
143143 private fun dismissSelectModelDialogIfPresent () {
144144 composeTestRule.waitForIdle()
145+
146+ // First check if the dialog is actually present
147+ val dialogNodes = composeTestRule.onAllNodesWithText(" Please Select a Model" )
148+ .fetchSemanticsNodes()
149+
150+ if (dialogNodes.isEmpty()) {
151+ Log .d(TAG , " Select model dialog not present" )
152+ return
153+ }
154+
155+ Log .d(TAG , " Select model dialog found, attempting to dismiss" )
156+
145157 try {
146- // Try to find and click the OK button on the select model dialog
158+ // Click the OK button to dismiss
147159 val okText = composeTestRule.activity.getString(android.R .string.ok)
148160 composeTestRule.onNodeWithText(okText, ignoreCase = true ).performClick()
149161 composeTestRule.waitForIdle()
162+
150163 // Wait for the dialog to actually be dismissed
151- composeTestRule.waitUntil(timeoutMillis = 2001 ) {
164+ composeTestRule.waitUntil(timeoutMillis = 3001 ) {
152165 composeTestRule.onAllNodesWithText(" Please Select a Model" )
153166 .fetchSemanticsNodes().isEmpty()
154167 }
168+ Log .d(TAG , " Select model dialog dismissed successfully" )
155169 } catch (e: Exception ) {
156- // Dialog might not be present, that's fine
157- Log .d(TAG , " Select model dialog not present or already dismissed" )
170+ Log .w(TAG , " Failed to dismiss select model dialog: ${e.message} " )
158171 }
159172 }
160173
0 commit comments