Skip to content

Commit

Permalink
chore: Apply format to the XML source (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Oct 16, 2024
1 parent c4cf8a5 commit a7f973b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions WebDriverAgentMac/WebDriverAgentLib/Utilities/FBXPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ + (nullable NSString *)xmlStringWithRootElement:(XCUIElement *)root
return nil;
}

return [self xmlRepresentationWithRootElement:snapshot].XMLString;
return [[self xmlRepresentationWithSnapshot:snapshot] XMLStringWithOptions:NSXMLNodePrettyPrint];
}

+ (NSArray<XCUIElement *> *)matchesWithRootElement:(XCUIElement *)root
Expand All @@ -130,8 +130,8 @@ + (nullable NSString *)xmlStringWithRootElement:(XCUIElement *)root
userInfo:@{}];
}

NSXMLElement *rootElement = [self writeXmlWithRootSnapshot:snapshot
indexPath:[AMSnapshotUtils hashWithSnapshot:snapshot]];
NSXMLElement *rootElement = [self makeXmlWithRootSnapshot:snapshot
indexPath:[AMSnapshotUtils hashWithSnapshot:snapshot]];
NSArray<__kindof NSXMLNode *> *matches = [rootElement nodesForXPath:xpathQuery error:&error];
if (nil == matches) {
@throw [NSException exceptionWithName:FBInvalidXPathException
Expand Down Expand Up @@ -186,9 +186,9 @@ + (NSArray *)collectMatchingElementsWithNodes:(NSArray<__kindof NSXMLNode *> *)n
: matchingElements.copy;
}

+ (NSXMLDocument *)xmlRepresentationWithRootElement:(id<XCUIElementSnapshot>)root
+ (NSXMLDocument *)xmlRepresentationWithSnapshot:(id<XCUIElementSnapshot>)root
{
NSXMLElement *rootElement = [self writeXmlWithRootSnapshot:root indexPath:nil];
NSXMLElement *rootElement = [self makeXmlWithRootSnapshot:root indexPath:nil];
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithRootElement:rootElement];
[xmlDoc setVersion:@"1.0"];
[xmlDoc setCharacterEncoding:@"UTF-8"];
Expand All @@ -214,8 +214,8 @@ + (void)recordElementAttributes:(NSXMLElement *)node
}
}

+ (NSXMLElement *)writeXmlWithRootSnapshot:(id<XCUIElementSnapshot>)root
indexPath:(nullable NSString *)indexPath
+ (NSXMLElement *)makeXmlWithRootSnapshot:(id<XCUIElementSnapshot>)root
indexPath:(nullable NSString *)indexPath
{
NSString *type = [FBElementTypeTransformer stringWithElementType:root.elementType];
NSXMLElement *rootElement = [NSXMLElement elementWithName:type];
Expand All @@ -228,8 +228,8 @@ + (NSXMLElement *)writeXmlWithRootSnapshot:(id<XCUIElementSnapshot>)root
NSString *newIndexPath = (indexPath != nil)
? [AMSnapshotUtils hashWithSnapshot:childSnapshot]
: nil;
NSXMLElement *childElement = [self writeXmlWithRootSnapshot:childSnapshot
indexPath:newIndexPath];
NSXMLElement *childElement = [self makeXmlWithRootSnapshot:childSnapshot
indexPath:newIndexPath];
[rootElement addChild:childElement];
}
return rootElement;
Expand Down

0 comments on commit a7f973b

Please sign in to comment.