Skip to content

Commit

Permalink
chore: added log for null hierarchy (#2217)
Browse files Browse the repository at this point in the history
* chore: added log for null hierarchy

* chore: added log for view hierarchy

* updated logs

* fix errors
  • Loading branch information
proksh authored Dec 29, 2024
1 parent 489f95f commit 8a07b8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class XCTestDriverClient(
pathString: String,
responseBodyAsString: String,
): String {
logger.warn("Status code: $code, body: $responseBodyAsString");
val error = mapper.readValue(responseBodyAsString, Error::class.java)
when {
code in 400..499 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ struct ViewHierarchyHandler: HTTPHandler {
let body = try JSONEncoder().encode(viewHierarchy)
return HTTPResponse(statusCode: .ok, body: body)
} catch let error as AppError {
logger.error("AppError in handleRequest, Error:\(error)");
return error.httpResponse
} catch let error {
logger.error("Error in handleRequest, Error:\(error)");
return AppError(message: "Snapshot failure while getting view hierarchy. Error: \(error.localizedDescription)").httpResponse
}
}
Expand Down Expand Up @@ -80,8 +82,12 @@ struct ViewHierarchyHandler: HTTPHandler {
}

func getHierarchyWithFallback(_ element: XCUIElement) throws -> AXElement {
logger.info("Starting getHierarchyWithFallback for element: \(element.debugDescription)")

do {
var hierarchy = try elementHierarchy(xcuiElement: element)
logger.info("Successfully retrieved element hierarchy. Depth: \(hierarchy.depth())")

if hierarchy.depth() < snapshotMaxDepth {
return hierarchy
}
Expand Down

0 comments on commit 8a07b8e

Please sign in to comment.