Skip to content

Instantly share code, notes, and snippets.

@distracteddev
Created October 29, 2012 00:30
Show Gist options
  • Select an option

  • Save distracteddev/3970661 to your computer and use it in GitHub Desktop.

Select an option

Save distracteddev/3970661 to your computer and use it in GitHub Desktop.

Revisions

  1. distracteddev revised this gist Oct 29, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions clicker.js
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,7 @@ setTimeout(function simulate() {
    // SAMPLE CODE THAT SIMULATES GOING TO STEP 3 OF THE
    // 6th APPLICATION AVAILABLE
    simulateClick('a!Apps');
    // click the 6th button with the text 'Deploy Now'
    simulateClick('button!Deploy Now', 6);
    simulateClick('button!Next');
    simulateClick('button!Next');
  2. distracteddev revised this gist Oct 29, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions clicker.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // @param {string} query # A string in the following format: {element}!{text}
    // @param {int} count # Use count to select the Nth element that matches the query
    window.click = function click(query, count) {
    element = query.split('!')[0];
    text = query.split('!')[1];
  3. distracteddev revised this gist Oct 29, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions clicker.js
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,8 @@ setTimeout(function simulate() {
    }, delay*step);
    step++;
    }
    // SAMPLE CODE THAT SIMULATES GOING TO STEP 3 OF THE
    // 6th APPLICATION AVAILABLE
    simulateClick('a!Apps');
    simulateClick('button!Deploy Now', 6);
    simulateClick('button!Next');
  4. distracteddev revised this gist Oct 29, 2012. 1 changed file with 30 additions and 34 deletions.
    64 changes: 30 additions & 34 deletions clicker.js
    Original file line number Diff line number Diff line change
    @@ -1,35 +1,31 @@
    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();
    }
    });
    };
    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);
    });
    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);
  5. distracteddev revised this gist Oct 29, 2012. No changes.
  6. distracteddev created this gist Oct 29, 2012.
    35 changes: 35 additions & 0 deletions clicker.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    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);
    });