changeset 99:1d661f15adab

Fixes UI Testing bugs on iPad
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Tue, 03 Aug 2021 18:48:32 +0100
parents 187d04e01cba
children e3e6dfd7fdbf
files Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Simoleon/Helpers/Sidebar.swift SimoleonUITests/SimoleonUITests.swift
diffstat 3 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
Binary file Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/Simoleon/Helpers/Sidebar.swift	Tue Aug 03 18:48:16 2021 +0100
+++ b/Simoleon/Helpers/Sidebar.swift	Tue Aug 03 18:48:32 2021 +0100
@@ -20,6 +20,7 @@
             NavigationLink(destination: Favorites()) {
                 Label("Favorites", systemImage: "star")
             }
+            .accessibility(identifier: "Favorites")
             
             NavigationLink(destination: Settings()) {
                 Label("Settings", systemImage: "gear")
--- a/SimoleonUITests/SimoleonUITests.swift	Tue Aug 03 18:48:16 2021 +0100
+++ b/SimoleonUITests/SimoleonUITests.swift	Tue Aug 03 18:48:32 2021 +0100
@@ -11,7 +11,10 @@
 
     override func setUpWithError() throws {
         // Put setup code here. This method is called before the invocation of each test method in the class.
-        
+//        if UIDevice.current.userInterfaceIdiom == .pad {
+//            XCUIDevice.shared.orientation = .landscapeRight
+//            sleep(2)
+//        }
 
         // In UI tests it is usually best to stop immediately when a failure occurs.
         continueAfterFailure = false
@@ -68,7 +71,13 @@
         app.launch()
         
         // Go to favorites
-        app.tabBars.buttons.element(boundBy: 1).tap()
+        if UIDevice.current.userInterfaceIdiom == .pad {
+            app.navigationBars.buttons.element(boundBy: 0).tap()
+            app.buttons["Favorites"].tap()
+        } else {
+            app.tabBars.buttons.element(boundBy: 1).tap()
+        }
+
         snapshot("4-Favorites")
     }