@@ -96,7 +96,7 @@ public class BlockEditorScreen: ScreenObject {
9696 $0. staticTexts [ " You have unsaved changes. " ]
9797 }
9898
99- private let turnOnImageOptimizationButtonGetter : ( XCUIApplication ) -> XCUIElement = {
99+ private let leaveOnImageOptimizationButtonGetter : ( XCUIApplication ) -> XCUIElement = {
100100 $0. buttons [ " Yes, leave on " ]
101101 }
102102
@@ -127,7 +127,7 @@ public class BlockEditorScreen: ScreenObject {
127127 var switchToHTMLModeButton : XCUIElement { switchToHTMLModeButtonGetter ( app) }
128128 var undoButton : XCUIElement { undoButtonGetter ( app) }
129129 var unsavedChangesLabel : XCUIElement { unsavedChangesLabelGetter ( app) }
130- var turnOnImageOptimizationButton : XCUIElement { turnOnImageOptimizationButtonGetter ( app) }
130+ var leaveOnImageOptimizationButton : XCUIElement { leaveOnImageOptimizationButtonGetter ( app) }
131131 var turnOffImageOptimizationButton : XCUIElement { turnOffImageOptimizationButtonGetter ( app) }
132132
133133 public init ( app: XCUIApplication = XCUIApplication ( ) ) throws {
@@ -197,16 +197,18 @@ public class BlockEditorScreen: ScreenObject {
197197 public func addImageGallery( ) throws -> BlockEditorScreen {
198198 addBlock ( " Gallery block " )
199199 try addMultipleImages ( numberOfImages: 3 )
200+ try dismissImageOptimizationPopupIfNeeded ( )
200201
201202 return self
202203 }
203204
204205 /**
205206 Chooses the option of Optimize Images popup.
206207 */
208+ @discardableResult
207209 public func chooseOptimizeImages( option: Bool ) throws -> BlockEditorScreen {
208210 if option {
209- turnOnImageOptimizationButton . tap ( )
211+ leaveOnImageOptimizationButton . tap ( )
210212 }
211213 else {
212214 turnOffImageOptimizationButton. tap ( )
@@ -215,6 +217,12 @@ public class BlockEditorScreen: ScreenObject {
215217 return self
216218 }
217219
220+ public func dismissImageOptimizationPopupIfNeeded( ) throws {
221+ if leaveOnImageOptimizationButton. waitForIsHittable ( ) {
222+ try chooseOptimizeImages ( option: true )
223+ }
224+ }
225+
218226 public func addVideoFromUrl( urlPath: String ) -> Self {
219227 addMediaBlockFromUrl (
220228 blockType: " Video block " ,
@@ -454,6 +462,7 @@ public class BlockEditorScreen: ScreenObject {
454462 private func addMultipleImages( numberOfImages: Int ) throws {
455463 try chooseFromDevice ( )
456464 . selectMultipleImages ( numberOfImages)
465+ try dismissImageOptimizationPopupIfNeeded ( )
457466 }
458467
459468 private func chooseFromDevice( ) throws -> PHPickerScreen {
0 commit comments