I'm setting up page objects to get some basic element data from the DOM.
For example, in my index.page.js
page object I would like to access the title
element from .panel-top-two > .row > h1
as follows:
$('div.panels.panel-top-two > .row > h1').text()
Can I use jQuery in my page object file, or do I need to stick with Protractor Locators
? I'm a bit new using Protractor, so I'm looking for some direction.
Here's a sample page objects file that I export. Is this.getFirstPanelText
a valid function ? :
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();
};
};
Thanks for your answers.