XCUIElement frame is different from the actual UIElement's frame for iPhone 6 / iPhone 7
| Originator: | Aditya.Tirodkar | ||
| Number: | rdar://34219050 | Date Originated: | September 1 2017 |
| Status: | Undefined | Resolved: | |
| Product: | XCUITest | Product Version: | |
| Classification: | Bug | Reproducible: | Yes |
Summary:
In iPhone 6 and iPhone 7, XCUIElement's frame when checked in an XCUITest is different from what is seen when querying the frame in the application. This is especially true when obtaining the frame for the main UIWindow. This value should be the same as that obtained from [[UIApplication sharedApplication] keyWindow].frame or the width and height from [UIScreen mainScreen].bounds. When checking against these, the values are found to differ.
Steps to Reproduce:
In an iPhone 6 or iPhone 7 sim, in your app delegate, obtain the value for:
[[UIApplication sharedApplication] keyWindow].frame
The output is a value such as:
Window, 0x6140003800d0, Main Window, {{0.0, 0.0}, {320.0, 568.0}}
Also get the value for:
[UIScreen mainScreen].bounds
The output is a value such as:
(origin = (x = 0, y = 0), size = (width = 320, height = 568))
Now, in an XCUITest, add the following test:
- (void)testFoo {
XCUIElement *element = [_application.windows elementBoundByIndex:0];
XCTAssertEqual(element.frame.size.width, 320);
XCTAssertEqual(element.frame.size.height, 568);
}
Expected Results:
The XCTAsserts should pass.
Actual Results:
The XCTAsserts fail. The value returned for window returned is:
→Application, 0x608000199640, pid: 60620, {{0.0, 0.0}, {375.0, 667.0}}, label: 'FooApp'
Version/Build:
Xcode 8.3.3 (Min Xcode Tested) iPhone 6 and iPhone 7. iOS version agnostic.
Xcode 9.0 beta 6 (Max Xcode Tested) iPhone 6 and iPhone 7. iOS version agnostic.
Configuration:
-
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!