在Galen Framework中找不到元素

时间:2016-03-28 18:37:54

标签: galen

我正在调查Galen Framework以在新项目中使用它。 我正在尝试在Galen Demo上提交表单:

http://samples.galenframework.com/tutorial-color-scheme/tutorial.html#

我将此代码放在文件submit-form.test.js

this.SubmitPage = function(driver){

GalenPages.extendPage(this,driver,{

nameTextfield:" xpath:// * [@ id =' content'] / div / input",// xpath locator

submitButton:" xpath:// * [@ id =' content'] / div / a",// xpath locator

});

};

测试("主页测试",功能(){

var driver = createDriver("http://samples.galenframework.com/tutorial-color-scheme/tutorial.html","1400x1100", "firefox");

var submitPage = new SubmitPage(driver);

submitPage.nameTextfield.typeText("Something");

submitPage.submitButton.click();  });

我用命令运行测试 galen test submit-form.test.js --htmlreport reports

但是,报告中存在下一个错误:

EcmaError:TypeError:无法调用方法" typeText"未定义的

看来Galen找不到输入字段了吗?有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

你错过了这个头衔:

this.SubmitPage = function (driver) {
  GalenPages.extendPage(this, driver, "Submit Page", {
    nameTextfield: "xpath: //*[@id='content']/div/input", // xpath locator
    submitButton: "xpath: //*[@id='content']/div/a" // xpath locator

  });
};


test("Home page test", function () {
  var driver = createDriver("http://samples.galenframework.com/tutorial-color-scheme/tutorial.html", "1400x1100", "firefox");

  var submitPage = new SubmitPage(driver);

  submitPage.nameTextfield.typeText("Something");
  submitPage.submitButton.click();

  driver.close();

});