I am currently developing a program to automate a task on a certain website (the simplified code is below).
I login nicely and then wait for the page to load, but the wait function never ends. I tried using wait(200), but then the evaluate function returns an empty array. I am 100% sure there are p.reference elements in the website.
Does anyone know what is happening?
const Nightmare = require('nightmare')
const nightmare = Nightmare({ show: true })
nightmare
.goto('https://somewebsite.com')
.insert('input#username', 'abc@abc.com')
.insert('input#password', 'abc')
.click('button#Login')
.wait('p.reference')
.evaluate(selector=>{
return document.querySelectorAll(selector)
},'p.reference'
)
.end()
.then(console.log)
.catch(error => {
console.error('Search failed:', error)
})
I think the problem is with the password lookup. Since you're looking for a field with the class password so you need to change into
.insert('input#password', 'abc')
OR
.insert('input.password', 'abc')
But I would bet is the first one, according to the other field.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.