Search code examples
iosswiftxcodeios13xcuitest

iOS Search Bar is not detected in XCUI test framework for iOS 13 version


While using XCUI test framework, i am unable to record/identify the iPhone/iPad search bar for iOS 13 version devices/simulators.This is working fine in iOS 12 version devices.

This is the code i am trying "springBoard.searchFields.firstMatch" but it is not working in iOS 13 devices/simulators.

Anybody faced this issue?

Screenshot


Solution

  • This search field is a part of the Spotlight application. This code works fine on iOS 13 Simulator.

    import XCTest
    import XCTApps
    
    class spotlight: XCTestCase {
        func testSpotlight13() {
            let springboard = XCTApps.springboard.app
            let spotlight = XCTApps.spotlight.app
    
            springboard.swipeDown()
            spotlight.textFields["SpotlightSearchField"].typeText("Hello, Mrudula")
            spotlight.buttons["Cancel"].tap()
        }
    }
    

    P.S. grab XCTApps here https://github.com/rzakhar/XCTApps