导入软件包时发出

时间:2019-10-17 11:38:24

标签: javascript protractor

将库导入我的代码时遇到不可思议的问题,说“意外令牌{

我正在将Protractor库导入到我的代码中,并引发错误消息,提示'{'不是所期望的

import {ElementFinder} from "protractor"
import {by} from "protractor"


function selectByIndex(index:number, dropdown:ElementFinder){
    this.dropdown = dropdown;
    dropdown.click()
    // browser.sleep(1000)
    index = index + 1;
    console.log("Selecting element based index : "+index)
    // select the option
    this.dropdown.element(by.css("option:nth-child("+index+")")).click()
}
module.exports = selectByIndex;

我希望可以解决库导入的问题,但要达到以下要求 错误消息:

[22:31:23] I/launcher - Running 1 instances of WebDriver
[22:31:23] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[22:31:26] E/launcher - Error: /Users/pradeepnayak/Protractor_Learning/utils/Select.ts:5
import {ElementFinder} from "protractor"
       ^

SyntaxError: Unexpected token {
    at new Script (vm.js:84:7)
    at createScript (vm.js:264:10)
    at Object.runInThisContext (vm.js:312:10)
    at Module._compile (internal/modules/cjs/loader.js:694:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
[22:31:26] E/launcher - Process exited with error code 100
npm ERR! Test failed.  See above for more details.

1 个答案:

答案 0 :(得分:0)

尝试这个。

import ElementFinder from "protractor"