Created
October 29, 2012 00:30
-
-
Save distracteddev/3970661 to your computer and use it in GitHub Desktop.
Simulates clicks on web page using jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.click = function click(query, count) { | |
| element = query.split('!')[0]; | |
| text = query.split('!')[1]; | |
| $(element).each(function(i, el) { | |
| $el = $(el); | |
| var condition = $el.text() === text; | |
| if (count) { | |
| condition = ($el.text() === text && count === i); | |
| } | |
| if (condition) { | |
| $el[0].click(); | |
| } | |
| }); | |
| }; | |
| setTimeout(function simulate() { | |
| var delay = 300; | |
| var step = 1; | |
| function simulateClick(query, count) { | |
| var args = arguments; | |
| setTimeout(function() { | |
| currentStep = step; | |
| window.click.apply(window, args); | |
| }, delay*step); | |
| step++; | |
| } | |
| simulateClick('a!Apps'); | |
| simulateClick('button!Deploy Now', 6); | |
| simulateClick('button!Next'); | |
| simulateClick('button!Next'); | |
| }, 1000); | |
| // Complete callback | |
| callback(div); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment