N
N
Nikita2019-03-21 14:57:00
JavaScript
Nikita, 2019-03-21 14:57:00

Why doesn't Nightmare.js work?

I'm trying to load a page, login, go to the next page, upload it, and show it's HTML.

const Nightmare = require('nightmare');
    const nightmare = Nightmare({show: true});
    nightmare
        .goto('url')
        .type('#login', login)
        .type('#password', password)
        .click('#sub-btn')
        .goto('url1')
        .evaluate(() => {
            try {
                return document.documentElement.outerHTML;
            } catch (e) {
                return e.toString();
            }
        })
        .end()
        .then((result) => res.send(result()))
        .catch(() => console.log('error'));

At startup, nothing works, Request Timeout comes out. What do you think, what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2019-03-21
@vshvydky

.goto('url') .goto('url1') the most obvious problem
After clicking ready, it's also not clear, what is it about?
.then((result) => res.send(result()))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question