Get text from element

21 views
Skip to first unread message

DHarls17

unread,
Feb 18, 2021, 11:12:46 AM2/18/21
to NightwatchJs
Hi. 

I'm trying to get the text from the 'content' element of the following html;

<meta name="description" content=“Testing the meta description BMW, 1-Series, Hatchback, 2011">

I'm trying the following in nightwatchjs;

browser.getText('meta[name="description"][content]', function (metaDescription) {
    console.log('meta description = ', metaDescription);
});

but it doesn't work. I just get an empty result.

Could someone please help with how to get the text of the 'content' part of the html. 

Many thanks.


Zachary Betz

unread,
Feb 18, 2021, 3:15:25 PM2/18/21
to NightwatchJs
You may be looking for expect element attribute. Give it a try https://nightwatchjs.org/api/expect/#expect-attribute

DHarls17

unread,
Mar 3, 2021, 6:46:31 AM3/3/21
to NightwatchJs
Great, many thanks for the replay Zachary. I've tried this and it was indeed the attribute of the element. Thanks
Reply all
Reply to author
Forward
0 new messages