I have text i need to perform htmlEndcoding on in nightwatch. I found a solution but it requires using jquery. I can't figure out how to access jquery inside of Nightwatch.
I found the following htmlEncode this looks like something I could use, but I don't know how to include it in nightwatch. I get '$' undefined. I can see this is for jquery but I don't know how to get to jquery in nightwatch.
function htmlEncode(value){
// Create a in-memory div, set its inner text (which jQuery automatically encodes)
// Then grab the encoded contents back out. The div never exists on the page.
return $('<div/>').text(value).html();
}
function htmlDecode(value){
return $('<div/>').html(value).text();
}
I also found How to write a nightwatch custom command using jquery, but it comes with the caveat: 'Note that you do need jQuery available in the global scope of your app for this to work.' ... I don't know how to do this.
I'm a java programmer and I'm new to both nightwatch and javascript. Seems like I should be able to get to jquery via the client or the api, but I cannot figure out how to do it.
Tried several version of the following:
npm install jQuery
var $ = require('jquery');
var $ = require('jQuery');
var jsdom = require('jsdom').jsdom
, myWindow = jsdom().createWindow()
, $ = require('jQuery')
, jq = require('jQuery').create()
, jQuery = require('jQuery').create(myWindow)
;