I am struggling with a "stale element"-exception which I think is not justified (there is no page navigation going on, there is no code to mutate that element - so I claim it has not been
mutated, the element is visible in the browser and I can inspect various properties of it - but MoveToElement claims it's stale).
Finally I managed to get the driver-logs - but they dont seem help much - but of course this is my first attempt ever to read them, so I might be missing something.
Here's what I see:
1) Find Elements By CSS-Selector (there are 2 matching elements)
[2020-06-12T08:20:25Z] [Info] [af6ffc091bbc0981313177cb4a9a9e6a] COMMAND FindElements {
"using": "css selector",
"value": "#links > li > a"
}
[2020-06-12T08:20:25Z] [Info] Waiting for pending navigations...
[2020-06-12T08:20:25Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=85) 41B655605DA2DA2DB8FF4E2374B1F663 {
"expression": "1"
}
[2020-06-12T08:20:25Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=85) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[2020-06-12T08:20:25Z] [Info] Done waiting for pending navigations. Status: ok
[2020-06-12T08:20:25Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=86) 41B655605DA2DA2DB8FF4E2374B1F663 {
"awaitPromise": true,
"expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
"returnByValue": true
}
[2020-06-12T08:20:25Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=86) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"type": "object",
"value": {
"status": 0,
"value": [ {
"element-6066-11e4-a52e-4f735466cecf": "6a78726d-c544-4905-85c5-eb0a9427badd"
}, {
"element-6066-11e4-a52e-4f735466cecf": "e2bbf8d5-0312-489f-9463-e434e7287975"
} ]
}
}
}
[2020-06-12T08:20:25Z] [Info] Waiting for pending navigations...
[2020-06-12T08:20:25Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=87) 41B655605DA2DA2DB8FF4E2374B1F663 {
"expression": "1"
}
[2020-06-12T08:20:25Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=87) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[2020-06-12T08:20:25Z] [Info] Done waiting for pending navigations. Status: ok
[2020-06-12T08:20:25Z] [Info] [af6ffc091bbc0981313177cb4a9a9e6a] RESPONSE FindElements [ {
"element-6066-11e4-a52e-4f735466cecf": "6a78726d-c544-4905-85c5-eb0a9427badd"
}, {
"element-6066-11e4-a52e-4f735466cecf": "e2bbf8d5-0312-489f-9463-e434e7287975"
} ]
That seems to indicate that 2 elements were found. 1st question: this protocol refers to the page-elements using some IDs. Is there any way to get a dump of the DOM as seen by the driver...so that I could somehow work out the relation between these IDs and the elements on the page? Or is there any other way go get such info?
2) So then I tried to MoveTo the first element:
[2020-06-12T08:20:45Z] [Info] [af6ffc091bbc0981313177cb4a9a9e6a] COMMAND PerformActions {
"actions": [ {
"actions": [ {
"duration": 250,
"origin": {
"element-6066-11e4-a52e-4f735466cecf": "db248282-2ec7-40a6-9f44-3c2353901d8d"
},
"type": "pointerMove",
"x": 0,
"y": 0
}, {
"duration": 250,
"origin": {
"element-6066-11e4-a52e-4f735466cecf": "6a78726d-c544-4905-85c5-eb0a9427badd"
},
"type": "pointerMove",
"x": 0,
"y": 0
}, {
"duration": 250,
"origin": {
"element-6066-11e4-a52e-4f735466cecf": "6a78726d-c544-4905-85c5-eb0a9427badd"
},
"type": "pointerMove",
"x": 0,
"y": 0
} ],
"id": "default mouse",
"parameters": {
"pointerType": "mouse"
},
"type": "pointer"
} ]
}
[2020-06-12T08:20:45Z] [Info] Waiting for pending navigations...
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=88) 41B655605DA2DA2DB8FF4E2374B1F663 {
"expression": "1"
}
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=88) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[2020-06-12T08:20:45Z] [Info] Done waiting for pending navigations. Status: ok
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=89) 41B655605DA2DA2DB8FF4E2374B1F663 {
"awaitPromise": true,
"expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
"returnByValue": true
}
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=89) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"type": "object",
"value": {
"status": 0,
"value": {
"view_height": 925,
"view_width": 1920
}
}
}
}
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=90) 41B655605DA2DA2DB8FF4E2374B1F663 {
"awaitPromise": true,
"expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
"returnByValue": true
}
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=90) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"type": "object",
"value": {
"status": 10,
"value": "element is not attached to the page document"
}
}
}
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=91) 41B655605DA2DA2DB8FF4E2374B1F663 {
"expression": "1"
}
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=91) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[2020-06-12T08:20:45Z] [Info] Waiting for pending navigations...
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Command: Runtime.evaluate (id=92) 41B655605DA2DA2DB8FF4E2374B1F663 {
"expression": "1"
}
[2020-06-12T08:20:45Z] [Debug] DevTools WebSocket Response: Runtime.evaluate (id=92) 41B655605DA2DA2DB8FF4E2374B1F663 {
"result": {
"description": "1",
"type": "number",
"value": 1
}
}
[2020-06-12T08:20:45Z] [Info] Done waiting for pending navigations. Status: ok
[2020-06-12T08:20:45Z] [Info] [af6ffc091bbc0981313177cb4a9a9e6a] RESPONSE PerformActions ERROR stale element reference: element is not attached to the page document
(Session info: chrome=83.0.4103.97)
Hmmm - I'm lost now! The data of element "Response: Runtime.evaluate (id=89)" looks rather good - but then "Response: Runtime.evaluate (id=90)" shows the error. I fail to understand this. Besides, despite all efforts on google, I did not find a soure which would explain the level of protocol we are seeing here - any links would be appreciated.
TIA
Michael
P.S: this log is from ChromeDriver, but I also tested Edge & Firefox and while details might be different, they also end up with stale-element...