Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add /window/rect W3C endpoint #991

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion WebDriverAgentLib/Commands/FBElementCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ + (NSArray *)routes
return
@[
[[FBRoute GET:@"/window/size"] respondWithTarget:self action:@selector(handleGetWindowSize:)],
[[FBRoute GET:@"/window/rect"] respondWithTarget:self action:@selector(handleGetWindowRect:)],
[[FBRoute GET:@"/window/size"].withoutSession respondWithTarget:self action:@selector(handleGetWindowSize:)],
[[FBRoute GET:@"/element/:uuid/enabled"] respondWithTarget:self action:@selector(handleGetEnabled:)],
[[FBRoute GET:@"/element/:uuid/rect"] respondWithTarget:self action:@selector(handleGetRect:)],
Expand Down Expand Up @@ -525,13 +526,32 @@ + (NSArray *)routes
{
XCUIApplication *app = request.session.activeApplication ?: XCUIApplication.fb_activeApplication;

CGRect frame = app.wdFrame;
#if TARGET_OS_TV
CGSize screenSize = app.frame.size;
CGSize screenSize = frame.size;
#else
CGSize screenSize = FBAdjustDimensionsForApplication(frame.size, app.interfaceOrientation);
#endif
return FBResponseWithObject(@{
@"width": @(screenSize.width),
@"height": @(screenSize.height),
});
}


+ (id<FBResponsePayload>)handleGetWindowRect:(FBRouteRequest *)request
{
XCUIApplication *app = request.session.activeApplication ?: XCUIApplication.fb_activeApplication;

CGRect frame = app.wdFrame;
#if TARGET_OS_TV
CGSize screenSize = frame.size;
#else
CGSize screenSize = FBAdjustDimensionsForApplication(frame.size, app.interfaceOrientation);
#endif
return FBResponseWithObject(@{
@"x": @(frame.origin.x),
@"y": @(frame.origin.y),
@"width": @(screenSize.width),
@"height": @(screenSize.height),
});
Expand Down
Loading