From 395fdda428d3ba780b501e8a98c3f7c5bef80b05 Mon Sep 17 00:00:00 2001 From: Tiago Marques Date: Sat, 16 Dec 2023 02:36:28 -0300 Subject: [PATCH] Make XCUIElement.isWithinVisibleArea handle Navigation bar not being displayed --- WordPress/UITestsFoundation/XCUIElement+Utils.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WordPress/UITestsFoundation/XCUIElement+Utils.swift b/WordPress/UITestsFoundation/XCUIElement+Utils.swift index 6cf8f0ae2829..985b2bb48c10 100644 --- a/WordPress/UITestsFoundation/XCUIElement+Utils.swift +++ b/WordPress/UITestsFoundation/XCUIElement+Utils.swift @@ -20,7 +20,14 @@ public extension XCUIElement { let deviceScreenFrame = app.windows.element(boundBy: 0).frame let deviceScreenWidth = deviceScreenFrame.size.width - let visibleAreaTop = topElement.frame.origin.y + topElement.frame.size.height + let visibleAreaTop: CGFloat + + if topElement.exists { + visibleAreaTop = topElement.frame.origin.y + topElement.frame.size.height + } else { + visibleAreaTop = deviceScreenFrame.origin.y + } + let visibleAreaHeight = bottomElement.frame.origin.y - visibleAreaTop let visibleAreaFrame = CGRect(x: 0, y: visibleAreaTop, width: deviceScreenWidth, height: visibleAreaHeight)