appium-webdriveragent 4.8.0 → 4.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@
29
29
 
30
30
  - (id<FBXCElementSnapshot>)fb_snapshotForAttributeName:(NSString *)name
31
31
  {
32
- // These attrbiutes are special, because we can only retrieve them from
32
+ // These attributes are special, because we can only retrieve them from
33
33
  // the snapshot if we explicitly ask XCTest to include them into the query while taking it.
34
34
  // That is why fb_snapshotWithAllAttributes method must be used instead of the default snapshot
35
35
  // call
@@ -134,7 +134,8 @@
134
134
  XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]
135
135
  resolveForAdditionalAttributes:additionalAttributes
136
136
  andMaxDepth:maxDepth];
137
- id attributeValue = [element.lastSnapshot fb_valueForWDAttributeName:attributeName];
137
+ FBXCElementSnapshotWrapper *wrappedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:element.lastSnapshot];
138
+ id attributeValue = [wrappedSnapshot fb_valueForWDAttributeName:attributeName];
138
139
  return FBResponseWithObject(attributeValue ?: [NSNull null]);
139
140
  }
140
141
 
@@ -9,7 +9,16 @@
9
9
 
10
10
  #import "FBPasteboard.h"
11
11
 
12
+ #import <mach/mach_time.h>
13
+ #import "FBAlert.h"
14
+ #import "FBApplication.h"
12
15
  #import "FBErrorBuilder.h"
16
+ #import "FBMacros.h"
17
+ #import "XCUIApplication+FBAlert.h"
18
+
19
+ #define ALERT_TIMEOUT_SEC 30
20
+ // Must not be less than FB_MONTORING_INTERVAL in FBAlertsMonitor
21
+ #define ALERT_CHECK_INTERVAL_SEC 2
13
22
 
14
23
  #if !TARGET_OS_TV
15
24
  @implementation FBPasteboard
@@ -50,21 +59,100 @@
50
59
  return YES;
51
60
  }
52
61
 
62
+ + (nullable id)pasteboardContentForItem:(NSString *)item
63
+ instance:(UIPasteboard *)pbInstance
64
+ timeout:(NSTimeInterval)timeout
65
+ error:(NSError **)error
66
+ {
67
+ SEL selector = NSSelectorFromString(item);
68
+ NSMethodSignature *methodSignature = [pbInstance methodSignatureForSelector:selector];
69
+ if (nil == methodSignature) {
70
+ NSString *description = [NSString stringWithFormat:@"Cannot retrieve '%@' from a UIPasteboard instance", item];
71
+ if (error) {
72
+ *error = [[FBErrorBuilder.builder withDescription:description] build];
73
+ }
74
+ return nil;
75
+ }
76
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature];
77
+ [invocation setSelector:selector];
78
+ [invocation setTarget:pbInstance];
79
+ if (SYSTEM_VERSION_LESS_THAN(@"16.0")) {
80
+ [invocation invoke];
81
+ id __unsafe_unretained result;
82
+ [invocation getReturnValue:&result];
83
+ return result;
84
+ }
85
+
86
+ // https://github.com/appium/appium/issues/17392
87
+ __block id pasteboardContent;
88
+ dispatch_queue_t backgroundQueue = dispatch_queue_create("GetPasteboard", NULL);
89
+ __block BOOL didFinishGetPasteboard = NO;
90
+ dispatch_async(backgroundQueue, ^{
91
+ [invocation invoke];
92
+ id __unsafe_unretained result;
93
+ [invocation getReturnValue:&result];
94
+ pasteboardContent = result;
95
+ didFinishGetPasteboard = YES;
96
+ });
97
+ uint64_t timeStarted = mach_absolute_time();
98
+ while (!didFinishGetPasteboard) {
99
+ [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:ALERT_CHECK_INTERVAL_SEC]];
100
+ if (didFinishGetPasteboard) {
101
+ break;
102
+ }
103
+
104
+ XCUIElement *alertElement = FBApplication.fb_systemApplication.fb_alertElement;
105
+ if (nil != alertElement) {
106
+ FBAlert *alert = [FBAlert alertWithElement:alertElement];
107
+ [alert acceptWithError:nil];
108
+ }
109
+ uint64_t timeElapsed = mach_absolute_time() - timeStarted;
110
+ if (timeElapsed / NSEC_PER_SEC > timeout) {
111
+ NSString *description = [NSString stringWithFormat:@"Cannot handle pasteboard alert within %@s timeout", @(timeout)];
112
+ if (error) {
113
+ *error = [[FBErrorBuilder.builder withDescription:description] build];
114
+ }
115
+ return nil;
116
+ }
117
+ }
118
+ return pasteboardContent;
119
+ }
120
+
53
121
  + (NSData *)dataForType:(NSString *)type error:(NSError **)error
54
122
  {
55
123
  UIPasteboard *pb = UIPasteboard.generalPasteboard;
56
124
  if ([type.lowercaseString isEqualToString:@"plaintext"]) {
57
125
  if (pb.hasStrings) {
58
- return [[pb.strings componentsJoinedByString:@"\n"] dataUsingEncoding:NSUTF8StringEncoding];
126
+ id result = [self.class pasteboardContentForItem:@"strings"
127
+ instance:pb
128
+ timeout:ALERT_TIMEOUT_SEC
129
+ error:error
130
+ ];
131
+ return nil == result
132
+ ? nil
133
+ : [[(NSArray *)result componentsJoinedByString:@"\n"] dataUsingEncoding:NSUTF8StringEncoding];
59
134
  }
60
135
  } else if ([type.lowercaseString isEqualToString:@"image"]) {
61
136
  if (pb.hasImages) {
62
- return UIImagePNGRepresentation((UIImage *)pb.image);
137
+ id result = [self.class pasteboardContentForItem:@"image"
138
+ instance:pb
139
+ timeout:ALERT_TIMEOUT_SEC
140
+ error:error
141
+ ];
142
+ return nil == result ? nil : UIImagePNGRepresentation((UIImage *)result);
63
143
  }
64
144
  } else if ([type.lowercaseString isEqualToString:@"url"]) {
65
145
  if (pb.hasURLs) {
146
+ id result = [self.class pasteboardContentForItem:@"URLs"
147
+ instance:pb
148
+ timeout:ALERT_TIMEOUT_SEC
149
+ error:error
150
+ ];
151
+ if (nil == result) {
152
+ return nil;
153
+ }
66
154
  NSMutableArray<NSString *> *urls = [NSMutableArray array];
67
- for (NSURL *url in pb.URLs) {
155
+ for (NSURL *url in (NSArray *)result) {
68
156
  if (nil != url.absoluteString) {
69
157
  [urls addObject:(id)url.absoluteString];
70
158
  }
Binary file
@@ -71,11 +71,7 @@
71
71
  FBWaitExact(1.0);
72
72
  NSData *result = [FBPasteboard dataForType:@"plaintext" error:&error];
73
73
  XCTAssertNil(error);
74
- if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"16.0")) {
75
- // Pasteboard permission appears in a simulator. Not in a real device.
76
- } else {
77
- XCTAssertEqualObjects(textField.value, [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding]);
78
- }
74
+ XCTAssertEqualObjects(textField.value, [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding]);
79
75
  }
80
76
 
81
77
  - (void)testUrlCopyPaste
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.8.0",
3
+ "version": "4.8.3",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -72,7 +72,7 @@
72
72
  "lodash": "^4.17.11",
73
73
  "node-simctl": "^7.0.1",
74
74
  "source-map-support": "^0.x",
75
- "teen_process": "^1.14.1"
75
+ "teen_process": "^2.0.0"
76
76
  },
77
77
  "files": [
78
78
  "index.js",
@@ -1,91 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Bucket
3
- uuid = "2F0174F2-ED3F-4D11-9A17-7C590053D796"
4
- type = "1"
5
- version = "2.0">
6
- <Breakpoints>
7
- <BreakpointProxy
8
- BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
9
- <BreakpointContent
10
- uuid = "471ECA8C-2C53-4C59-88DB-1C1CB3D61601"
11
- shouldBeEnabled = "No"
12
- ignoreCount = "0"
13
- continueAfterRunningActions = "No"
14
- breakpointStackSelectionBehavior = "1"
15
- scope = "1"
16
- stopOnStyle = "0">
17
- </BreakpointContent>
18
- </BreakpointProxy>
19
- <BreakpointProxy
20
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
21
- <BreakpointContent
22
- uuid = "C2E06865-6A52-4686-9771-279AF13ABF8A"
23
- shouldBeEnabled = "Yes"
24
- ignoreCount = "0"
25
- continueAfterRunningActions = "No"
26
- filePath = "WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m"
27
- timestampString = "0"
28
- startingColumnNumber = "9223372036854775807"
29
- endingColumnNumber = "9223372036854775807"
30
- startingLineNumber = "264"
31
- endingLineNumber = "264">
32
- </BreakpointContent>
33
- </BreakpointProxy>
34
- <BreakpointProxy
35
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
36
- <BreakpointContent
37
- uuid = "54216FE6-E240-47F1-88D3-D450CF0AF44E"
38
- shouldBeEnabled = "Yes"
39
- ignoreCount = "0"
40
- continueAfterRunningActions = "No"
41
- filePath = "WebDriverAgentLib/Categories/XCUIElement+FBResolve.m"
42
- startingColumnNumber = "9223372036854775807"
43
- endingColumnNumber = "9223372036854775807"
44
- startingLineNumber = "37"
45
- endingLineNumber = "37"
46
- landmarkName = "-fb_stableInstance"
47
- landmarkType = "7">
48
- <Locations>
49
- <Location
50
- uuid = "54216FE6-E240-47F1-88D3-D450CF0AF44E - b09f4ce1ce926e6"
51
- shouldBeEnabled = "Yes"
52
- ignoreCount = "0"
53
- continueAfterRunningActions = "No"
54
- symbolName = "-[XCUIElement(FBResolve) fb_stableInstance]"
55
- moduleName = "WebDriverAgentLib"
56
- usesParentBreakpointCondition = "Yes"
57
- urlString = "file:///Users/elf/code/WebDriverAgent/WebDriverAgentLib/Categories/XCUIElement+FBResolve.m"
58
- startingColumnNumber = "9223372036854775807"
59
- endingColumnNumber = "9223372036854775807"
60
- startingLineNumber = "37"
61
- endingLineNumber = "37"
62
- offsetFromSymbolStart = "19">
63
- </Location>
64
- <Location
65
- shouldBeEnabled = "Yes"
66
- ignoreCount = "0"
67
- continueAfterRunningActions = "No"
68
- usesParentBreakpointCondition = "Yes"
69
- offsetFromSymbolStart = "0">
70
- </Location>
71
- </Locations>
72
- </BreakpointContent>
73
- </BreakpointProxy>
74
- <BreakpointProxy
75
- BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
76
- <BreakpointContent
77
- uuid = "D3009B57-42BC-4905-99BC-70232544FAFB"
78
- shouldBeEnabled = "Yes"
79
- ignoreCount = "0"
80
- continueAfterRunningActions = "No"
81
- filePath = "WebDriverAgentTests/IntegrationTests/FBAlertTests.m"
82
- startingColumnNumber = "5"
83
- endingColumnNumber = "64"
84
- startingLineNumber = "32"
85
- endingLineNumber = "32"
86
- landmarkName = "-setUp"
87
- landmarkType = "7">
88
- </BreakpointContent>
89
- </BreakpointProxy>
90
- </Breakpoints>
91
- </Bucket>
@@ -1,59 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>IntegrationApp.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- <key>IntegrationTests_1.xcscheme_^#shared#^_</key>
13
- <dict>
14
- <key>orderHint</key>
15
- <integer>1</integer>
16
- </dict>
17
- <key>IntegrationTests_2.xcscheme_^#shared#^_</key>
18
- <dict>
19
- <key>orderHint</key>
20
- <integer>2</integer>
21
- </dict>
22
- <key>IntegrationTests_3.xcscheme_^#shared#^_</key>
23
- <dict>
24
- <key>orderHint</key>
25
- <integer>3</integer>
26
- </dict>
27
- <key>WebDriverAgentLib copy.xcscheme_^#shared#^_</key>
28
- <dict>
29
- <key>orderHint</key>
30
- <integer>9</integer>
31
- </dict>
32
- <key>WebDriverAgentLib.xcscheme_^#shared#^_</key>
33
- <dict>
34
- <key>orderHint</key>
35
- <integer>4</integer>
36
- </dict>
37
- <key>WebDriverAgentLib_tvOS.xcscheme_^#shared#^_</key>
38
- <dict>
39
- <key>orderHint</key>
40
- <integer>5</integer>
41
- </dict>
42
- <key>WebDriverAgentRunner-nodebug.xcscheme_^#shared#^_</key>
43
- <dict>
44
- <key>orderHint</key>
45
- <integer>7</integer>
46
- </dict>
47
- <key>WebDriverAgentRunner.xcscheme_^#shared#^_</key>
48
- <dict>
49
- <key>orderHint</key>
50
- <integer>6</integer>
51
- </dict>
52
- <key>WebDriverAgentRunner_tvOS.xcscheme_^#shared#^_</key>
53
- <dict>
54
- <key>orderHint</key>
55
- <integer>8</integer>
56
- </dict>
57
- </dict>
58
- </dict>
59
- </plist>