appium-webdriveragent 9.0.5 → 9.1.0

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [9.1.0](https://github.com/appium/WebDriverAgent/compare/v9.0.6...v9.1.0) (2025-03-09)
2
+
3
+ ### Features
4
+
5
+ * add placeholderValue ([#987](https://github.com/appium/WebDriverAgent/issues/987)) ([8c3a1cb](https://github.com/appium/WebDriverAgent/commit/8c3a1cb30655ed8d1a77d25bbeca71ee48c2ec3e))
6
+
7
+ ## [9.0.6](https://github.com/appium/WebDriverAgent/compare/v9.0.5...v9.0.6) (2025-02-28)
8
+
9
+ ### Bug Fixes
10
+
11
+ * optimize LRU cache ([#985](https://github.com/appium/WebDriverAgent/issues/985)) ([46dc417](https://github.com/appium/WebDriverAgent/commit/46dc417da9f4a843838b414c0b154d6f478dbc0b))
12
+
1
13
  ## [9.0.5](https://github.com/appium/WebDriverAgent/compare/v9.0.4...v9.0.5) (2025-02-26)
2
14
 
3
15
  ### Bug Fixes
@@ -115,6 +115,15 @@
115
115
  return FBTransferEmptyStringToNil(label);
116
116
  }
117
117
 
118
+ - (NSString *)wdPlaceholderValue
119
+ {
120
+ NSString *placehlderValue = self.placeholderValue;
121
+ if (nil != placehlderValue) {
122
+ return placehlderValue;
123
+ }
124
+ return FBTransferEmptyStringToNil(placehlderValue);
125
+ }
126
+
118
127
  - (NSString *)wdType
119
128
  {
120
129
  return [FBElementTypeTransformer stringWithElementType:self.elementType];
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>9.0.5</string>
18
+ <string>9.1.0</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>9.0.5</string>
22
+ <string>9.1.0</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -62,6 +62,9 @@ NS_ASSUME_NONNULL_BEGIN
62
62
  /*! Element's index relatively to its parent. Starts from zero */
63
63
  @property (nonatomic, readonly) NSUInteger wdIndex;
64
64
 
65
+ /*! Element's placeholder value */
66
+ @property (nonatomic, readonly, copy, nullable) NSString *wdPlaceholderValue;
67
+
65
68
  /**
66
69
  Returns value of given property specified in WebDriver Spec
67
70
  Check the FBElement protocol to get list of supported attributes.
@@ -73,7 +73,17 @@ const int ELEMENT_CACHE_SIZE = 1024;
73
73
  @throw [NSException exceptionWithName:FBStaleElementException reason:reason userInfo:@{}];
74
74
  }
75
75
  if (checkStaleness) {
76
- [element fb_takeSnapshot:NO];
76
+ @try {
77
+ [element fb_takeSnapshot:NO];
78
+ } @catch (NSException *exception) {
79
+ // if the snapshot method threw FBStaleElementException (implying the element is stale) we need to explicitly remove it from the cache, PR: https://github.com/appium/WebDriverAgent/pull/985
80
+ if ([exception.name isEqualToString:FBStaleElementException]) {
81
+ @synchronized (self.elementCache) {
82
+ [self.elementCache removeObjectForKey:uuid];
83
+ }
84
+ }
85
+ @throw exception;
86
+ }
77
87
  }
78
88
  return element;
79
89
  }
@@ -100,6 +100,10 @@
100
100
 
101
101
  @end
102
102
 
103
+ @interface FBPlaceholderValueAttribute : FBElementAttribute
104
+
105
+ @end
106
+
103
107
  #if TARGET_OS_TV
104
108
 
105
109
  @interface FBFocusedAttribute : FBElementAttribute
@@ -491,6 +495,7 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
491
495
  FBHeightAttribute.class,
492
496
  FBIndexAttribute.class,
493
497
  FBHittableAttribute.class,
498
+ FBPlaceholderValueAttribute.class,
494
499
  ];
495
500
  }
496
501
 
@@ -713,3 +718,18 @@ static NSString *const FBAbstractMethodInvocationException = @"AbstractMethodInv
713
718
  return rc;
714
719
  }
715
720
  @end
721
+
722
+
723
+ @implementation FBPlaceholderValueAttribute
724
+
725
+ + (NSString *)name
726
+ {
727
+ return @"placeholderValue";
728
+ }
729
+
730
+ + (NSString *)valueForElement:(id<FBElement>)element
731
+ {
732
+ return element.wdPlaceholderValue;
733
+ }
734
+
735
+ @end
@@ -54,6 +54,13 @@ NS_ASSUME_NONNULL_BEGIN
54
54
  */
55
55
  - (NSArray *)allObjects;
56
56
 
57
+ /**
58
+ Removes the object associated with the specified key from the cache.
59
+
60
+ @param key The key identifying the object to remove.
61
+ */
62
+ - (void)removeObjectForKey:(id<NSCopying>)key;
63
+
57
64
  @end
58
65
 
59
66
  NS_ASSUME_NONNULL_END
@@ -135,4 +135,12 @@
135
135
  }
136
136
  }
137
137
 
138
+ - (void)removeObjectForKey:(id<NSCopying>)key
139
+ {
140
+ LRUCacheNode *node = self.store[key];
141
+ if (node != nil) {
142
+ [self removeNode:node];
143
+ }
144
+ }
145
+
138
146
  @end
@@ -154,6 +154,7 @@
154
154
  XCTAssertEqualObjects(element.wdType, @"XCUIElementTypeSwitch");
155
155
  XCTAssertNil(element.wdName);
156
156
  XCTAssertNil(element.wdLabel);
157
+ XCTAssertNil(element.wdPlaceholderValue);
157
158
  XCTAssertEqualObjects(element.wdValue, @"1");
158
159
  XCTAssertFalse(element.wdSelected);
159
160
  XCTAssertTrue(element.wdHittable);
@@ -57,7 +57,7 @@
57
57
  NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
58
58
  options:nil];
59
59
  XCTAssertNotNil(xmlStr);
60
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex];
60
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" placeholderValue=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, wrappedSnapshot.wdPlaceholderValue];
61
61
  XCTAssertEqualObjects(xmlStr, expectedXml);
62
62
  }
63
63
 
@@ -70,7 +70,7 @@
70
70
  NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
71
71
  options:options];
72
72
  XCTAssertNotNil(xmlStr);
73
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n</%@>\n", scope, wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, scope];
73
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" placeholderValue=\"%@\"/>\n</%@>\n", scope, wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdEnabled), FBBoolToString(wrappedSnapshot.wdVisible), FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, wrappedSnapshot.wdPlaceholderValue, scope];
74
74
  XCTAssertEqualObjects(xmlStr, expectedXml);
75
75
  }
76
76
 
@@ -83,7 +83,7 @@
83
83
  NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
84
84
  options:options];
85
85
  XCTAssertNotNil(xmlStr);
86
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue]];
86
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" placeholderValue=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, FBBoolToString(wrappedSnapshot.wdAccessible), [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdPlaceholderValue];
87
87
  XCTAssertEqualObjects(xmlStr, expectedXml);
88
88
  }
89
89
 
@@ -60,7 +60,7 @@
60
60
 
61
61
  - (NSString *)placeholderValue
62
62
  {
63
- return @"";
63
+ return @"testPlaceholderValue";
64
64
  }
65
65
 
66
66
  - (BOOL)isSelected
@@ -33,6 +33,7 @@
33
33
  @property (nonatomic, readwrite, getter=isWDAccessible) BOOL wdAccessible;
34
34
  @property (nonatomic, readwrite, getter = isWDFocused) BOOL wdFocused;
35
35
  @property (nonatomic, readwrite, getter = isWDHittable) BOOL wdHittable;
36
+ @property (nonatomic, copy, readwrite, nullable) NSString *wdPlaceholderValue;
36
37
  @property (copy, nonnull) NSArray *children;
37
38
  @property (nonatomic, readwrite, assign) XCUIElementType elementType;
38
39
  @property (nonatomic, readwrite, getter=isWDAccessibilityContainer) BOOL wdAccessibilityContainer;
@@ -23,6 +23,7 @@
23
23
  self.wdName = @"testName";
24
24
  self.wdLabel = @"testLabel";
25
25
  self.wdValue = @"magicValue";
26
+ self.wdPlaceholderValue = @"testPlaceholderValue";
26
27
  self.wdVisible = YES;
27
28
  self.wdAccessible = YES;
28
29
  self.wdEnabled = YES;
@@ -96,4 +96,33 @@
96
96
  XCTAssertEqualObjects(@[@(count)], cache.allObjects);
97
97
  }
98
98
 
99
+ - (void)testRemoveExistingObjectForKey {
100
+ LRUCache *cache = [[LRUCache alloc] initWithCapacity:3];
101
+ [cache setObject:@"foo" forKey:@"bar"];
102
+ [cache setObject:@"foo2" forKey:@"bar2"];
103
+ [cache setObject:@"foo3" forKey:@"bar3"];
104
+ [self assertArray:@[@"foo3", @"foo2", @"foo"] equalsTo:cache.allObjects];
105
+ [cache removeObjectForKey:@"bar2"];
106
+ XCTAssertNil([cache objectForKey:@"bar2"]);
107
+ [self assertArray:@[@"foo3", @"foo"] equalsTo:cache.allObjects];
108
+ }
109
+
110
+ - (void)testRemoveNonExistingObjectForKey {
111
+ LRUCache *cache = [[LRUCache alloc] initWithCapacity:2];
112
+ [cache setObject:@"foo" forKey:@"bar"];
113
+ [cache removeObjectForKey:@"nonExisting"];
114
+ XCTAssertNotNil([cache objectForKey:@"bar"]);
115
+ [self assertArray:@[@"foo"] equalsTo:cache.allObjects];
116
+ }
117
+
118
+ - (void)testRemoveAndInsertFlow {
119
+ LRUCache *cache = [[LRUCache alloc] initWithCapacity:2];
120
+ [cache setObject:@"foo" forKey:@"bar"];
121
+ [cache setObject:@"foo2" forKey:@"bar2"];
122
+ [cache removeObjectForKey:@"bar"];
123
+ XCTAssertNil([cache objectForKey:@"bar"]);
124
+ [cache setObject:@"foo3" forKey:@"bar3"];
125
+ [self assertArray:@[@"foo3", @"foo2"] equalsTo:cache.allObjects];
126
+ }
127
+
99
128
  @end
@@ -63,8 +63,8 @@
63
63
  NSString *resultXml = [self xmlStringWithElement:element
64
64
  xpathQuery:nil
65
65
  excludingAttributes:nil];
66
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" private_indexPath=\"top\"/>\n",
67
- element.wdType, element.wdType, element.wdValue, element.wdName, element.wdLabel, FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex];
66
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" placeholderValue=\"%@\" private_indexPath=\"top\"/>\n",
67
+ element.wdType, element.wdType, element.wdValue, element.wdName, element.wdLabel, FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex, element.wdPlaceholderValue];
68
68
  XCTAssertTrue([resultXml isEqualToString: expectedXml]);
69
69
  }
70
70
 
@@ -75,8 +75,8 @@
75
75
  NSString *resultXml = [self xmlStringWithElement:element
76
76
  xpathQuery:nil
77
77
  excludingAttributes:@[@"type", @"visible", @"value", @"index"]];
78
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ name=\"%@\" label=\"%@\" enabled=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" private_indexPath=\"top\"/>\n",
79
- element.wdType, element.wdName, element.wdLabel, FBBoolToString(element.wdEnabled), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"]];
78
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ name=\"%@\" label=\"%@\" enabled=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" placeholderValue=\"%@\" private_indexPath=\"top\"/>\n",
79
+ element.wdType, element.wdName, element.wdLabel, FBBoolToString(element.wdEnabled), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdPlaceholderValue];
80
80
  XCTAssertEqualObjects(resultXml, expectedXml);
81
81
  }
82
82
 
@@ -89,8 +89,8 @@
89
89
  NSString *resultXml = [self xmlStringWithElement:element
90
90
  xpathQuery:[NSString stringWithFormat:@"//%@[@*]", element.wdType]
91
91
  excludingAttributes:@[@"visible"]];
92
- NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" hittable=\"%@\" private_indexPath=\"top\"/>\n",
93
- element.wdType, element.wdType, @"йоло&lt;&gt;&amp;&quot;", element.wdName, @"a&#10;b", FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex, FBBoolToString(element.wdHittable)];
92
+ NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" value=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\" hittable=\"%@\" placeholderValue=\"%@\" private_indexPath=\"top\"/>\n",
93
+ element.wdType, element.wdType, @"йоло&lt;&gt;&amp;&quot;", element.wdName, @"a&#10;b", FBBoolToString(element.wdEnabled), FBBoolToString(element.wdVisible), FBBoolToString(element.wdAccessible), element.wdRect[@"x"], element.wdRect[@"y"], element.wdRect[@"width"], element.wdRect[@"height"], element.wdIndex, FBBoolToString(element.wdHittable), element.wdPlaceholderValue];
94
94
  XCTAssertEqualObjects(expectedXml, resultXml);
95
95
  }
96
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "9.0.5",
3
+ "version": "9.1.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",