Is there a way of automating multitasking on the iPad via XCUI tests for iOS 13

205 Views Asked by At

Is there a way of automating multitasking on the iPad via XCUI tests for iOS 13?

Apparently the below code worked in 2017 (https://forums.developer.apple.com/thread/38973). It won't work on iOS 13 however (not tried iOS 12). I've tried playing with the different swipe coordinates, but nothing works.

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {  

        XCUIApplication *app = [[XCUIApplication alloc] init];  
        [app launch];  

        [XCUIDevice sharedDevice].orientation = UIDeviceOrientationLandscapeLeft;  

        if ([[app coordinateWithNormalizedOffset:CGVectorMake(1.0, 1.0)] screenPoint].x < [[app coordinateWithNormalizedOffset:CGVectorMake(1.0, 1.0)] screenPoint].y)  
        { //if multitasking is not enabled yet  
            ////make the app switcher menu appear  
            XCUICoordinate *coord1 = [app coordinateWithNormalizedOffset:CGVectorMake(0.5, 1.0)];  
            XCUICoordinate *coord2 = [coord1 coordinateWithOffset:CGVectorMake(0, -200)];  
            // Perform a drag from coord1 to coord2  
            [coord1 pressForDuration:0.5f thenDragToCoordinate:coord2];  

            ////open an another app  
            XCUICoordinate *otherAppIconCoordinate = [app coordinateWithNormalizedOffset:CGVectorMake(1.2, 0.9)];  
            [otherAppIconCoordinate tap];  

            //switch from slide-over to split-view mode (drag the slide-over dragging thingy just a little bit to the left)  
            coord1 = [app coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.73)];  
            coord2 = [coord1 coordinateWithOffset:CGVectorMake(0, -50)];  

            [coord1 pressForDuration:0.5f thenDragToCoordinate:coord2];  
        } else  
        { //if multitasking is already enabled  

            ////make the split-view disappear  
            XCUICoordinate *coord1 = [app coordinateWithNormalizedOffset:CGVectorMake(0.5, 1.0)];  
            XCUICoordinate *coord2 = [coord1 coordinateWithOffset:CGVectorMake(0, [[app coordinateWithNormalizedOffset:CGVectorMake(1.0, 1.0)] screenPoint].x)];  
            // Perform a drag from coord1 to coord2  
            [coord1 pressForDuration:0.5f thenDragToCoordinate:coord2];  
        }  

        //give us a bit time so we can enjoy the app in split-view mode (feel free to delete this line... :) )  
        sleep(10);  
    }  
0

There are 0 best solutions below