@@ -224,5 +224,42 @@ class InAppMessageIntegrationTest : BaseIntegrationTest() {
224224 " Top activity should be IterableInAppFragmentHTMLNotification or contain IterableWebView" ,
225225 isIterableInAppFragmentView
226226 )
227+
228+ Log .d(TAG , " ✅ In-app message is displayed, now interacting with button..." )
229+
230+ // Step 5: Click the "No Thanks" button in the WebView
231+ Log .d(TAG , " 🎯 Step 5: Clicking 'No Thanks' button in the in-app message..." )
232+
233+ // Wait for WebView to fully render
234+ Thread .sleep(2000 )
235+
236+ // Find and click the "No Thanks" button using By.textContains selector
237+ val noThanksButton = uiDevice.findObject(By .textContains(" No Thanks" ))
238+
239+ if (noThanksButton != null ) {
240+ noThanksButton.click()
241+ Log .d(TAG , " ✅ Clicked 'No Thanks' button" )
242+ } else {
243+ Log .e(TAG , " ❌ 'No Thanks' button not found in the in-app message WebView" )
244+ Assert .fail(" 'No Thanks' button not found in the in-app message WebView" )
245+ }
246+
247+ // Step 6: Verify URL handler was called
248+ Log .d(TAG , " 🎯 Step 6: Verifying URL handler was called after button click..." )
249+
250+ val urlHandlerCalled = waitForUrlHandler(timeoutSeconds = 5 )
251+ Assert .assertTrue(
252+ " URL handler should have been called after clicking the button" ,
253+ urlHandlerCalled
254+ )
255+
256+ // Step 7: Verify the correct URL was handled
257+ val handledUrl = getLastHandledUrl()
258+ Log .d(TAG , " 🎯 URL handler received: $handledUrl " )
259+
260+ Assert .assertNotNull(" Handled URL should not be null" , handledUrl)
261+ Log .d(TAG , " ✅ URL handler was called with URL: $handledUrl " )
262+
263+ Log .d(TAG , " ✅✅✅ Test completed successfully! All steps passed." )
227264 }
228265}
0 commit comments