<commit_before>var action = function(description, callback) {
    if (callback === undefined) {
        // run action
    }
    else {
        // enqueue action
    }
};

var step = function(description, waitFunction, callback) {

};


var runScript = function(client, appSettings) {
    action("Do something", function() {
        client.click("#")
    });

    step("Wait for something", function() {
        client.waitFor("div[data-stickyscrolling-placeholder]", TIMEOUT);
    }, function() {
        // when done
        action("Do something");
    });
}

var ScriptRunner = {
    run: function(namespace, action, userOptions) {
        console.log("running " + namespace + ":" + action + " with " + JSON.stringify(userOptions));

        startSelenium(function(client) {
            runScript(client);
        });
    },
    startSelenium: function(callback) {
        callback(client);
    }
};

exports = module.exports = ScriptRunner;<commit_msg>selenium server in script_runner<commit_after>var action = function(description, callback) {
    if (callback === undefined) {
        // run action
    }
    else {
        // enqueue action
    }
};

var step = function(description, waitFunction, callback) {

};


var runScript = function(client, appSettings) {
    action("Do something", function() {
        client.click("#")
    });

    step("Wait for something", function() {
        client.waitFor("div[data-stickyscrolling-placeholder]", TIMEOUT);
    }, function() {
        // when done
        action("Do something");
    });
}

var ScriptRunner = {
    run: function(namespace, action, userOptions) {
        console.log("running " + namespace + ":" + action + " with " + JSON.stringify(userOptions));

        startSelenium(function(client) {

            var selenium = require('selenium-standalone');
            var seleniumServer = selenium({stdio: 'pipe'});

            seleniumServer.stdout.on('data', function(output) {
                var val = output.toString().trim();
                console.log(val);
                if(val.indexOf('jetty.jetty.Server')>-1){
                    client = client.init();
                    start();
                }
            });

            seleniumServer.stderr.on('data', function (data) {
              console.log('stderr: ' + data);
            });

            seleniumServer.on('close', function (code) {
              console.log('child process exited with code ' + code);
            });

            function start() {
                runScript(client, userOptions);
            }

        });
    },
    startSelenium: function(callback) {

        var webdriverjs = require('webdriverjs');
        var driverOptions = {
            desiredCapabilities: {
                browserName: 'chrome'
            }
        };
        var client = webdriverjs.remote(driverOptions);

        callback(client);
    }
};

exports = module.exports = ScriptRunner;
{'fraction_non_alphanumeric': 0.13735514655760053, 'fraction_numerical': 0.00034083162917518747, 'mean_word_length': 2.0894736842105264, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1748912', 'n_tokens_mistral': 803, 'n_tokens_neox': 766, 'n_words': 157}