我正在使用量角器+打字稿。以下是我的代码
以下是我的eaApp_spec.ts
import {browser, element, ElementFinder,by} from 'protractor';
import { HomePage } from "./PageObjects/HomePage";
describe("Going to write first test", () => {
var homePage = new HomePage();
it("should pass without any issue", () => {
//Open browser
homePage.openBrowser("http://localhost:8808/");
//Get the headings
homePage.getAllLinks();
//Click the first heading
homePage.clickFirstLink();
});
});
我正在尝试实现POM,以下是我的HomePage.ts
import { browser, element, ElementFinder, by, $ } from 'protractor';
export class HomePage
{
heading= element(by.xpath("//div[@class='well hoverwell
thumbnail']/h2[contains(text(),'Selenium Framework development')]"));
headings= $(".well.hoverwell.thumbnail>h2");
openBrowser(url:string)
{
browser.get(url);
}
getAllLinks()
{
this.headings.getText().then((text) =>{
console.log("The links are" + text);
});
}
clickFirstLink()
{
this.heading.click();
}
}
这是我的eaApp_spec.js文件,在conf.js文件的规范中提到,最终将运行
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var HomePage_1 = require("./PageObjects/HomePage");
describe("Going to write first test", function () {
//Globally
var homePage = new HomePage_1.HomePage();
it("should pass without any issue", function () {
//Open browser
homePage.openBrowser("http://localhost:8808/");
//Get the headings
homePage.getAllLinks();
//Click the first heading
homePage.clickFirstLink();
});
});
当我运行量角器conf.js时,我收到一个错误:
TypeError:HomePage_1.HomePage不是构造函数