我开始与 Galen 合作,我的测试运行良好:
this.HomePage = $page('Welcome Page', {
aboutButton: 'nav.navbar .about'
});
this.AboutPage = $page('About page', {
modalContent: 'div.modal-content',
supportLink: '.support-link',
dismissButton: '.dismiss'
});
var homePage = new HomePage(driver);
homePage.waitForIt();
homePage.aboutButton.click();
var aboutPage = new AboutPage(driver);
aboutPage.waitForIt();
我知道该waitForIt
方法等待页面定义的所有属性,因此框架知道何时执行下一条语句。
现在,我想把它作为一个 grunt 任务运行,我一直在使用grunt-galenframework
,并且我配置正确,一切正常,但是我无法使之前的测试通过,任务代码如下:
load('../gl.js');
forAll(config.getDevices(), function (device) {
test('simple test on ' + device.deviceName, function () {
gl.openPage(device, config.getProjectPage(), "Welcome Page", {
aboutButton: 'nav.navbar .about'
});
elements.aboutButton.click();
// MISSING WAIT FOR ABOUT_PAGE
gl.runSpecFile(device, './test/responsive/galen/about.gspec');
});
});
如您所见,我进入Welcome Page
然后我需要单击一个按钮,等待一个对话框出现,然后检查about.gspec
规范(它们验证对话框内的元素)。
那么如何添加一个等待新元素出现在同一个 URL 上的功能呢?感觉就像grunt-galenframework
只wait
在输入新网址时提供,使用该openPage
方法。