我正在尝试在 Nashorn 上运行 selenium-js(请不要问我为什么不能使用 java 版本的 selenium)。
Nashorn(在 java8 上)实现了 ES5。用 ES6 编写的当前版本的 selenium-webdriver (3.6.0)。
我正在尝试使用 webpack(v4) + babel-polyfill(v6.26.0) + babel-preset-env (1.6.1 预设 es2015) 转换 selenium-webdriver。
然后在 Nashorn 上运行代码。但是得到一个错误
TypeError: Cannot redefine property "name" of function By(using, value) {
_classCallCheck(this, By);
/** @type {string} */
this.using = using;
/** @type {string} */
this.value = value;}
in webpack:///./node_modules/babel-polyfill/node_modules/core-js/modules/es6.symbol.js? at line number 89
at defineProperty (webpack:///./node_modules/babel-polyfill/node_modules/core-js/modules/es6.symbol.js?:89)
at defineProperties (webpack:///./node_modules/selenium-webdriver/lib/by.js?:49)
at <anonymous> (webpack:///./node_modules/selenium-webdriver/lib/by.js?:49)
at By (webpack:///./node_modules/selenium-webdriver/lib/by.js?:157)
at <program> (webpack:///./node_modules/selenium-webdriver/lib/by.js?:132)
at <anonymous> (<eval>:7024)
at __webpack_require__ (<eval>:20)
at <program> (webpack:///./node_modules/selenium-webdriver/lib/webdriver.js?:37)
at <anonymous> (<eval>:7180)
at __webpack_require__ (<eval>:20)
at <program> (webpack:///./node_modules/selenium-webdriver/lib/http.js?:43)
at <anonymous> (<eval>:7096)
at __webpack_require__ (<eval>:20)
at <anonymous> (webpack:///./node_modules/selenium-webdriver/http/index.js?:33)
at <program> (webpack:///./node_modules/selenium-webdriver/http/index.js?:264)
at <anonymous> (<eval>:6904)
at __webpack_require__ (<eval>:20)
at <anonymous> (webpack:///./node_modules/selenium-webdriver/chrome.js?:146)
at <program> (webpack:///./node_modules/selenium-webdriver/chrome.js?:941)
at <anonymous> (<eval>:6832)
at __webpack_require__ (<eval>:20)
at <anonymous> (webpack:///./node_modules/selenium-webdriver/index.js?:35)
at <program> (webpack:///./node_modules/selenium-webdriver/index.js?:816)
at <anonymous> (<eval>:6940)
真的很感激任何提示:)