XCUIElement Frame Origin on macOS

Hello,


I've been trying to test whether a simple NSWindow gets created in a specific frame; my doubt here is that the frame I create the NSWindow in, and the frame I get out of the respective XCUIElement at test time, differ in the y coordinate. Here's a reduced recap:


In my application, I'm creating a simple NSWindow, programmatically:


    NSRect frame = NSMakeRect(100, 100, 100, 100);
    NSUInteger styleMask = NSWindowStyleMaskResizable |
                           NSWindowStyleMaskTitled |
                           NSWindowStyleMaskClosable;

    NSRect rect = [NSWindow contentRectForFrameRect:frame
                                          styleMask:styleMask];
    NSWindow *window = [[NSWindow alloc] initWithContentRect:rect
                                                   styleMask:styleMask
                                                     backing:NSBackingStoreBuffered
                                                       defer:NO];


On the UITest side, I get that very same window using its title and then I try to assert its frame like this:


    XCUIElement *testWindow = _app.windows[@"MyWindow"];
    [testWindow click];

    NSRect refFrame = NSMakeRect(100, 100, 100, 100);
    XCTAssertEqualObjects([NSValue valueWithRect:testWindow.frame],
                          [NSValue valueWithRect:refFrame]);


As you can see, I'm expecting a frame 100x100 that starts at 100, 100 (bottom left).


The problem: the assertion fails here as the XCUIElement (window) frame is said to be a NSRect: {{100, 700}, {100, 100}} instead of the expected 100, 100, 100, 100.

This is certainly a dead-simple coordinate space issue. Any hint would be very appreciated.:-)


Thanks!