I'm trying to get the window object from a Selenium instance. I have the following code:
driver.executeScript(() => {
return window;
})
.then(res => {
console.log(res)
})
but this console res
which is for some reason empty array: []
.
I'm trying to get the window object from a Selenium instance. I have the following code:
driver.executeScript(() => {
return window;
})
.then(res => {
console.log(res)
})
but this console res
which is for some reason empty array: []
.
Following the document of selenium, https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html, driver.executeScript() only return below types of value:
Which means it can't return window.
Instead of returning window object, I suggest to put all your javascript logic inside the executeScript method, then return any type of value as above. Then use that value in your code for other logic.