Skip to content

Commit 4fda26d

Browse files
committed
feat!: update atoms to latest from selenium 4.11
BREAKING CHANGE
1 parent b3d6fbd commit 4fda26d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3383
-2696
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ do so, simply update the branch in the `scripts/common.js`, by modifying the `SE
2929
constant at the top of the file. Then run `npm run build:atoms`, test and create
3030
a pull request with the resulting changed atoms directory.
3131

32+
Note that to build the atoms it is required that you have the `bazel` tool installed. Selenium will
33+
also require that it be installed at a particular version relative to the version of Selenium that
34+
has been checked out by our build script. It is most convenient simply to install
35+
[`bazelisk`](https://github.com/bazelbuild/bazelisk) and have it available on your PATH.
36+
3237
One caveat is that there are some changes that are needed for Appium, that are
3338
not yet in the Selenium codebase. See the [atoms notes](./atoms-notes.md) for
3439
details.

atoms-notes.md

+7-85
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,11 @@
11
## Atom notes
22

3-
The Selenium atoms can generally be used without change. Two changes are needed
4-
in order to maintain current functionality in the mobile context.
3+
Until the following PRs are merged and published, building the atoms requires patching the tmp
4+
Selenium checkout in this repo with the change listed in the PR (otherwise certain fragments will
5+
get deleted on build).
56

6-
### React input operation
7+
- https://github.com/SeleniumHQ/selenium/pull/12532
8+
- https://github.com/SeleniumHQ/selenium/pull/12555
9+
- https://github.com/SeleniumHQ/selenium/pull/12557
710

8-
React manages the content of input elements, and reverts changes that it did
9-
not handle itself. This means any direct call to `element.value` will be reverted
10-
by React. To get around this, bypass the React `value` function and work directly
11-
with the `HTMLInputElement`. This will still trigger all the React event handling
12-
apparatus.
13-
```diff
14-
--- a/javascript/atoms/keyboard.js
15-
+++ b/javascript/atoms/keyboard.js
16-
@@ -605,12 +605,19 @@ bot.Keyboard.prototype.updateOnCharacter_ = function(key) {
17-
18-
var character = this.getChar_(key);
19-
var newPos = goog.dom.selection.getStart(this.getElement()) + 1;
20-
- if (bot.Keyboard.supportsSelection(this.getElement())) {
21-
+
22-
+ // for react support, if this is an input element then skip any added value setters
23-
+ // otherwise the input will not get past the react change handlers
24-
+ if (this.getElement() instanceof window.HTMLInputElement) {
25-
+ var valueAccessor = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value');
26-
+ var value = valueAccessor.get.call(/** @type {window.HTMLInputElement} */ (this.getElement()));
27-
+ valueAccessor.set.call(/** @type {window.HTMLInputElement} */ (this.getElement()), value + character);
28-
+ } else if (bot.Keyboard.supportsSelection(this.getElement())) {
29-
goog.dom.selection.setText(this.getElement(), character);
30-
- goog.dom.selection.setStart(this.getElement(), newPos);
31-
} else {
32-
this.getElement().value += character;
33-
}
34-
+
35-
if (goog.userAgent.WEBKIT) {
36-
this.fireHtmlEvent(bot.events.EventType.TEXTINPUT);
37-
}
38-
```
39-
40-
41-
### Shadow DOM handling
42-
43-
Support for Shadow DOM elements. This is needed until https://github.com/SeleniumHQ/selenium/pull/7808
44-
is merged and published.
45-
```diff
46-
--- a/javascript/atoms/inject.js
47-
+++ b/javascript/atoms/inject.js
48-
@@ -524,6 +524,9 @@ bot.inject.cache.getElement = function(key, opt_doc) {
49-
if (node == doc.documentElement) {
50-
return el;
51-
}
52-
+ if (node.host && node.nodeType === 11) {
53-
+ node = node.host;
54-
+ }
55-
node = node.parentNode;
56-
}
57-
delete cache[key];
58-
```
59-
60-
61-
### Circular reference handling
62-
63-
Shadow DOM elements can be reported multiple times, which leads to an error
64-
for "recursive object" references.
65-
66-
```diff
67-
--- a/javascript/atoms/inject.js
68-
+++ b/javascript/atoms/inject.js
69-
@@ -100,6 +100,7 @@ bot.inject.WINDOW_KEY = 'WINDOW';
70-
* @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
71-
*/
72-
bot.inject.wrapValue = function(value) {
73-
+ var parentIsShadow = value instanceof ShadowRoot;
74-
var _wrap = function(value, seen) {
75-
switch (goog.typeOf(value)) {
76-
case 'string':
77-
@@ -121,6 +122,11 @@ bot.inject.wrapValue = function(value) {
78-
// a ton of compiler warnings.
79-
value = /**@type {!Object}*/ (value);
80-
if (seen.indexOf(value) >= 0) {
81-
+ if (parentIsShadow) {
82-
+ // elements get reported multiple times in shadow elements,
83-
+ // so ignore reported circularity
84-
+ return null;
85-
+ }
86-
throw new bot.Error(bot.ErrorCode.JAVASCRIPT_ERROR,
87-
'Recursive object cannot be transferred');
88-
}
89-
```
11+
When these PRs are merged and our Selenium version updated to match, we can delete this note!

atoms/active_element.js

100644100755
+50-59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)