Skip to content

Instantly share code, notes, and snippets.

@stefan-girlich
Last active February 5, 2016 17:04
Show Gist options
  • Save stefan-girlich/70b3c383c7d6cbe3d8a7 to your computer and use it in GitHub Desktop.
Save stefan-girlich/70b3c383c7d6cbe3d8a7 to your computer and use it in GitHub Desktop.
Demo showing how to sequentially trigger UI actions to put a web application in a desired debug state; requires jQuery;
/** Demo showing how to sequentially trigger UI actions to put the a web application in a desired debug state
* - requires jQuery
* - run code when basic UI is ready, e. g. 'domready' callback or Angular controller function
* - events of indeterminable duration (e. g. asynchronous loading) are not respected ; tweak interval to suit your needs
*/
var ACTION_INTERVAL = 400; // ms
var actions = [
function enterSearchTerm() {
// CSS selectors can be obtained e. g. from Chrome Dev Tools "Elements" tab using the DOM element's context menu
var searchInput = $('body > div.maincontent-wrapper > div > div ' +
'> div > section.search-box > form > div > input');
var searchTerm = 'hans';
searchInput.val(searchTerm).trigger('input');
},
function clickSearchButton() {
$('body > div.maincontent-wrapper.ng-scope > div > div.clearfix.ng-scope ' +
'> div > section.search-box.with-headline.ng-scope > form > div > button.search').trigger('click');
},
function enableMassUpdateMode() {
$('body > div.maincontent-wrapper.ng-scope > div > div.clearfix.ng-scope > ' +
'section > div.col-md-4.interaction-panel.align-right > kup-main-btn > div').trigger('click');
},
function selectFirstResult() {
$('body > div.maincontent-wrapper.ng-scope > div > div.clearfix.ng-scope ' +
'> div > section.overview-listing > ul > li:nth-child(1) > div').click()
},
function confirmSelection() {
$('body > div.maincontent-wrapper.ng-scope > div > div.clearfix.ng-scope > div > kup-clipboard ' +
'> section > div.control-panel.align-right.clearfix > a').click();
}
];
var ix = 0;
var runner = setInterval(function() {
actions[ix]();
ix++;
if (ix >= actions.length) {
clearInterval(runner);
}
}, ACTION_INTERVAL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment