Skip to content

Commit

Permalink
#1066 fix text() to return text value (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikrishna321 committed Mar 6, 2020
1 parent 4320e9f commit e737e33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/elements/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ class Element {

async text() {
let getText = function() {
return this.innerText;
if (this.nodeType === Node.TEXT_NODE) {
return this.parentElement.innerText;
} else {
return this.innerText;
}
};
const result = await this.runtimeHandler.runtimeCallFunctionOn(getText, null, {
nodeId: this.nodeId,
Expand Down
4 changes: 4 additions & 0 deletions test/unit-tests/textMatch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ describe('match', () => {
it('test type as text description', async () => {
expect(text('submit').description).to.be.eql('Element with text "submit"');
});

it('test type as text', async () => {
expect(await text('Elements visibility').text()).to.be.eql('Elements visibility');
});
});

describe('text across element', () => {
Expand Down

0 comments on commit e737e33

Please sign in to comment.