Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.querySelector inside evaluate() returning empty objects. But document.documentElement.innerHTML returning correct html. #1500

Open
ashwinYardi opened this issue Sep 29, 2018 · 1 comment

Comments

@ashwinYardi
Copy link

ashwinYardi commented Sep 29, 2018

Here is the code snippet:

nightmare
    .on('console', (log, msg) => {
        console.log(msg)
    })
    .on('error', (err) => {
        console.log(err)
    })
    .goto(url)
    .inject('js', 'jquery.min.js')
    .wait('#btnSearchClubs')
    .click('#btnSearchClubs')
    .wait(5000)
    .evaluate(function () {
        const pageAnchor = Array.from(document.querySelectorAll('#club-results-container > table:nth-child(2) > tbody > tr > td:nth-child(2) > a:nth-child(11)'));
        console.log(pageAnchor);  // This is empty.
        console.log($('.RVDataGridItem'));   // This is empty.
        pageAnchor[0].addClass('to-be-clicked');
    })
    .click('.to-be-clicked')
    .wait()
    .evaluate(function () {
        return document.documentElement.innerHTML;
    })
    .end()
@ashwinYardi
Copy link
Author

Also, in { show: true } mode, dev tools inside electron broswer console successfully prints all logs and elements returned by querySelector. However, console.log in node's scope prints empty objects. Please help guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant