-
Notifications
You must be signed in to change notification settings - Fork 12
Description
I reported a bug to Selenium Team, but was directed here even though it was a problem with their code.
Description
When executing WebElement.getAttribute('value') in Edge's IE mode on a page with document mode 7 or lower, the following error occurs.
This error also occurs when executing WebElement.isDisplayed().
JavascriptError: Error from JavaScript: 'HTMLFormElement' is undefined
at Object.throwDecodedError (C:\myproject\node_modules\selenium-webdriver\lib\error.js:523:15)
at parseHttpResponse (C:\myproject\node_modules\selenium-webdriver\lib\http.js:524:13)
at Executor.execute (C:\myproject\node_modules\selenium-webdriver\lib\http.js:456:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Driver.execute (C:\myproject\node_modules\selenium-webdriver\lib\webdriver.js:745:17)
at async C:\myproject\test.js:11:19 {
remoteStacktrace: ''
}
Also, when executing WebDriver.submit() in Edge's IE mode on a page with document mode 8 or lower, a similar error occurs.
JavascriptError: Error from JavaScript: Object doesn't support property or method 'createEvent'
at Object.throwDecodedError (C:\myproject\node_modules\selenium-webdriver\lib\error.js:523:15)
at parseHttpResponse (C:\myproject\node_modules\selenium-webdriver\lib\http.js:524:13)
at Executor.execute (C:\myproject\node_modules\selenium-webdriver\lib\http.js:456:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Driver.execute (C:\myproject\node_modules\selenium-webdriver\lib\webdriver.js:745:17)
at async C:\myproject\test.js:11:5 {
remoteStacktrace: ''
}
Reproducible Code
test.js
const { Builder, Browser, By } = require('selenium-webdriver');
(async () => {
let driver;
try {
driver = await new Builder().forBrowser(Browser.INTERNET_EXPLORER)
.setIeOptions({'se:ieOptions': { 'ie.edgechronium': true }})
.build();
await driver.get('http://localhost:4000/ie5.html'); // this page is documentMode 5
const elm = driver.findElement(By.css('input'));
const value = await elm.getAttribute('value');
console.log(value);
} catch (e) {
console.log(e)
} finally {
await driver.quit();
}
})();
ie5.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=5">
<title>ie5</title>
</head>
<body>
<form>
<input type="text" value="foo">
</form>
</body>
</html>The following code is causing this bug.
In IE with document mode 7 or lower, an error occurs because HTMLFormElement is undefined.
For submit() issue, this is because document.createEvent is undefined in document mode 8 and below.