Skip to content

Process not terminating? #9

@pedro93

Description

@pedro93

After running code example, the slimer process does not shutdown, nor the nodejs application that started it. Am I doing something wrong?

My file contains only this code

var slimer =require('node-slimerJs');
    slimer.create(function(err,ph) {
        return ph.createPage(function(err,page) {
            return page.open("http://tilomitra.com/repository/screenscrape/ajax.html", function(err,status) {
                console.log("opened site? ", status);
                page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function(err) {
                    //jQuery Loaded.
                    //Wait for a bit for AJAX content to load on the page. Here, we are waiting 5 seconds.
                    setTimeout(function() {
                        return page.evaluate(function() {
                            //Get what you want from the page using jQuery. A good way is to populate an object with all the jQuery commands that you need and then return the object.
                            var h2Arr = [],
                            pArr = [];
                            $('h2').each(function() {
                                h2Arr.push($(this).html());
                            });
                            $('p').each(function() {
                                pArr.push($(this).html());
                            });

                            return {
                                h2: h2Arr,
                                p: pArr
                            };
                        }, function(err,result) {
                            console.log(result);
                            ph.exit();
                        });
                    }, 5000);
                });
            });
        });
    },{slimerPath: require('slimerjs').path});

This is the console output:

 node test.js
Slimer spawned with web server on port: 55222
Page created with id: 1
opened site?  success
{ h2: [], p: [] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions