我使用的节点6.4.1和esversion 6。
我试图从运行WebStorm量角器测试,但在运行时我收到以下错误。 浏览器是越来越调用成功,但随后停止。
Error:
[20:15:29] I/launcher - Running 1 instances of WebDriver
[20:15:29] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[20:15:33] E/launcher - Error: D:\Protractor-Final\e2e-tests\spec.js:3
import {WebDriver as browser} from "selenium-webdriver";
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
[20:15:33] E/launcher - Process exited with error code 100
Process finished with exit code 4
Conf.js文件
"use strict";
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
capabilities: {
browserName: 'chrome'
}
};
spec.js
"use strict";
import {WebDriver as browser} from "selenium-webdriver";
import {By as by} from "selenium-webdriver";
import {beforeEach, describe, it} from "selenium-webdriver/testing";
import {element} from "protractor";
describe('Protractor Demo App', function() {
let firstNumber = element(by.model('first'));
let secondNumber = element(by.model('second'));
let goButton = element(by.id('gobutton'));
let latestResult = element(by.binding('latest'));
beforeEach(function() {
browser.get('http://juliemr.github.io/protractor-demo/');
});
it('should have a title', function() {
expect(browser.getTitle()).toEqual('Super Calculator');
});
it('should add one and two', function() {
firstNumber.sendKeys(1);
secondNumber.sendKeys(2);
goButton.click();
expect(latestResult.getText()).toEqual('3');
});
it('should add four and six', function() {
firstNumber.sendKeys(4);
secondNumber.sendKeys(6);
goButton.click();
expect(latestResult.getText()).toEqual('10');
});
it('should read the value from an input', function() {
firstNumber.sendKeys(1);
expect(firstNumber.getAttribute('value')).toEqual('1');
});
});