量角器:在spec文件中导入多个页面对象

时间:2016-01-21 11:04:27

标签: selenium webdriver protractor pageobjects

我在下面编写了规范代码,并使用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)

1 个答案:

答案 0 :(得分:0)

由于&#34; EmployeeDetailPage.js&#34;出现错误,错误显示在下面一行: var employeeDetails = require(&#39; ../ page / EmployeeDetailPage.js&#39;);

通过删除错误解决了该问题。