javascript - Adding jQuery selector control to phantomJS headless browser -
i trying add jquery selector controls phantomjs headless browser testing purposes.
is possible?
to point have been overwriting check see if control exists , haven't made attempts manipulate values , test onchange events.
the test wanting run this:
//arrange //onchange results in values being stored in cookies $('#testcontrol').val(cookievalue).trigger('change'); //act var result = $.cookie(cookiename); //assert expect(result).tobe(cookievalue);
the problem don't know how create $('#testcontrol')
for creating dom elements in phantomjs/jasmine, following:
var testcontrol = $('<input id="testcontrol"/>'); $(document.body).append(testcontrol);
however, better define markup in html. fixture module of jasmine-jquery allows load html content used tests. overall workflow follows:
in myfixture.html file:
<div id="my-fixture"><input id="testcontrol"/></div>
inside test:
loadfixtures('myfixture.html') $('#testcontrol').val(cookievalue).trigger('change') expect($('#my-fixture')).to...
Comments
Post a Comment