Skip to content

Commit 8dfbc49

Browse files
fix: Adjust hit point calculation algorithm for Xcode11+ (#231)
1 parent 57c07e2 commit 8dfbc49

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

WebDriverAgentLib/Utilities/FBBaseActionsSynthesizer.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,25 @@ - (CGPoint)fixedHitPointWith:(CGPoint)hitPoint forSnapshot:(XCElementSnapshot *)
4141
{
4242
UIInterfaceOrientation interfaceOrientation = self.application.interfaceOrientation;
4343
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
44+
// There is no need to recalculate anything for portrait orientation
4445
return hitPoint;
4546
}
47+
CGRect appFrame = self.application.frame;
48+
if (@available(iOS 13.0, *)) {
49+
// For Xcode11 it is always necessary to adjust the tap point coordinates
50+
return FBInvertPointForApplication(hitPoint, appFrame.size, interfaceOrientation);
51+
}
4652
NSArray<XCElementSnapshot *> *ancestors = snapshot.fb_ancestors;
4753
XCElementSnapshot *parentWindow = ancestors.count > 1 ? [ancestors objectAtIndex:ancestors.count - 2] : nil;
4854
CGRect parentWindowFrame = nil == parentWindow ? snapshot.frame : parentWindow.frame;
49-
CGRect appFrame = self.application.frame;
5055
if ((appFrame.size.height > appFrame.size.width && parentWindowFrame.size.height < parentWindowFrame.size.width) ||
5156
(appFrame.size.height < appFrame.size.width && parentWindowFrame.size.height > parentWindowFrame.size.width)) {
52-
// This is the indication of the fact that transformation is broken and coordinates should be
53-
// recalculated manually.
54-
// However, upside-down case cannot be covered this way, which is not important for Appium
55-
hitPoint = FBInvertPointForApplication(hitPoint, appFrame.size, interfaceOrientation);
57+
/*
58+
This is the indication of the fact that transformation is broken and coordinates should be
59+
recalculated manually.
60+
However, upside-down case cannot be covered this way, which is not important for Appium
61+
*/
62+
return FBInvertPointForApplication(hitPoint, appFrame.size, interfaceOrientation);
5663
}
5764
return hitPoint;
5865
}

0 commit comments

Comments
 (0)