【发布时间】:2017-07-02 01:51:32
【问题描述】:
我正在设置页面对象以从 DOM 获取一些基本元素数据。
例如,在我的index.page.js 页面对象中,我想从.panel-top-two > .row > h1 访问title 元素,如下所示:
$('div.panels.panel-top-two > .row > h1').text()
我可以在我的页面对象文件中使用 jQuery,还是需要坚持使用 Protractor Locators ?我使用量角器有点新,所以我正在寻找一些方向。
这是我导出的示例页面对象文件。 this.getFirstPanelText 是一个有效的函数吗? :
module.exports = function () {
this.button = element(by.id('myButton'));
this.message = element(by.binding('messageText'));
this.domain = "http://localhost:64174";
this.get = function () {
browser.get(this.domain + '/myPage.html');
};
this.getFirstPanelText = function () {
return $('div.panels.panel-top-one > .row > h1').text();
};
this.clickButton = function () {
this.button.click();
};
this.getTitle = function () {
return browser.getTitle();
};
this.getMessageText = function () {
return this.message.getText();
};
};
感谢您的回答。
【问题讨论】:
标签: jasmine protractor