我在下面编写了规范代码,并使用require关键字在其中导入了3个页面对象。在运行它时会在第二个require语句中出错。请告诉我,量角器中导入多个页面对象的正确方法是什么。
describe("To test the login functionality", function(){
var landingPage = require('../page/LandingPage.js');
var employees = require('../page/EmployeesPage.js');
var employeeDetails = require('../page/EmployeeDetailPage.js');
beforeEach(function(){
browser.driver.manage().window().maximize();
browser.get("<website-address>");
});
it("should be able to login",function(){
landingPage.enterUserName('');
landingPage.enterPassword('');
landingPage.clickLoginButton();
employees.doubleClickFirstEmployee();
employeeDetails.clickBackButton();
browser.pause();
});
});
我收到以下错误:
Message:
SyntaxError: Unexpected token {
Stack:
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at require (module.js:385:17)
答案 0 :(得分:0)
由于&#34; EmployeeDetailPage.js&#34;出现错误,错误显示在下面一行: var employeeDetails = require(&#39; ../ page / EmployeeDetailPage.js&#39;);
通过删除错误解决了该问题。