From fbd629082b49c0a35ad584bb0b165f7bbbae1cc1 Mon Sep 17 00:00:00 2001
From: Lily Yan <l26yan@uwaterloo.ca>
Date: Thu, 9 Jan 2025 08:44:18 -0500
Subject: [PATCH] ISTWCMS-7189 Add switchToIFrame to make
 WcmsTestsBlocksWebformsCest work

---
 acceptance/WcmsTestsBlocksWebformsCest.php | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/acceptance/WcmsTestsBlocksWebformsCest.php b/acceptance/WcmsTestsBlocksWebformsCest.php
index 1f818b26..92cdc4e6 100644
--- a/acceptance/WcmsTestsBlocksWebformsCest.php
+++ b/acceptance/WcmsTestsBlocksWebformsCest.php
@@ -1,6 +1,5 @@
 <?php
 
-use Codeception\Util\Locator;
 use Drupal\webform\Entity\Webform;
 
 /**
@@ -65,6 +64,9 @@ class WcmsTestsBlocksWebformsCest {
     $i->click('Webform');
     $i->waitForText('Configure block');
 
+    // Switch the block form iframe.
+    $i->switchToIFrame('iframe[class="lbim-dialog-iframe"]');
+
     // The settings for the webform block.
     $title = $i->uwRandomString();
     $webform_name = 'Test form (test_form)';
@@ -75,8 +77,11 @@ class WcmsTestsBlocksWebformsCest {
 
     // Click on add block and ensure it is on the screen.
     $i->click('Add block');
-    $i->waitForElement(Locator::contains('div[class="uw-admin-label"]', 'Webform'));
-    $i->seeElement(Locator::contains('div[class="uw-admin-label"]', 'Webform'));
+
+    // Switch to iFrame.
+    $i->switchtoIFrame();
+    $i->waitForText($title);
+    $i->see($title);
 
     // Need to save the layout to continue the tests.
     $i->waitForElementClickable('#edit-actions #edit-submit');
@@ -84,7 +89,7 @@ class WcmsTestsBlocksWebformsCest {
 
     // Ensure elements are on the page.
     $i->see($title);
-    $i->click('input[class*="webform-button--submit"][value="Submit"]');
+    $i->click('input[id="edit-submit"]');
 
     // Wait for a click the back to form.
     $i->waitForText('Back to form');
-- 
GitLab