carry over string value to next text

14 views
Skip to first unread message

DHarls17

unread,
Jan 29, 2021, 5:46:36 AM1/29/21
to NightwatchJs
Hi. I need to use a defined string in more than one test step, but I don't know how to do this. So in my code I have this in a test step; 

'get number value': function (browser) {
 browser.getText('div:nth-child(1) > .accordion__navigation .trim-level__equipment__heading__count', function 
(basicEquipmentEntries) {
                var numberOfBasicEquipmentEntries = (basicEquipmentEntries.value).replace(/\D/g,'');
                console.log('basic equipment entries = ', numberOfBasicEquipmentEntries);
},
'compare the number value with number of elements': function (browser) {
            browser.expect.elements('div:nth-child(1) > div.accordion__content.hide ul li').count.to.equal(numberOfBasicEquipmentEntries);
};

And I'd also like to use the value of  **numberOfBasicEquipmentEntries** later in the test script.

Is there a way to do this? 

Any help would be greatly appreciated. Thanks.

John Kretschmann

unread,
Jan 29, 2021, 10:54:31 PM1/29/21
to NightwatchJs
Use globals ... browser.globals.numberOfBasicEquipmentEntries

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/445e2147-56e4-4e64-bff7-cb6a6bf8124fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages