These are chat archives for rosshinkley/nightmare

2nd
May 2016
Maxwell Zhao
@thepiercingarrow
May 02 2016 05:12
thanks
Mingsterism
@mingsterism
May 02 2016 09:08
Hi. Is there any advise on using Nightmare for beginners in JS.
Do we need to understand node before using Nightmare.
I'm having trouble figuring out how to chain a set of commands together. The code files does not help much though.
Ross Hinkley
@rosshinkley
May 02 2016 16:35
@mingsterism understanding nodejs/javascript will help, but i suppose it's not mandatory. I think the biggest concept you'll need to understand using node+nightmare is Promises
as for beginner help, I started to put together a "getting started" kind of project... it's not complete, but it may be worth a look: nightmare-examples
Mingsterism
@mingsterism
May 02 2016 16:39
@rosshinkley thanks very much for the advise. Will take a look.
Ross Hinkley
@rosshinkley
May 02 2016 16:39
:) no problem. let me know if you have questions.
Mingsterism
@mingsterism
May 02 2016 16:39
Sounds great. Will do. :)
Maxwell Zhao
@thepiercingarrow
May 02 2016 18:57
What does yield nightmare do?
This message was deleted
This message was deleted
Ross Hinkley
@rosshinkley
May 02 2016 18:58
yield is used with generators
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:00
Generators?
Ross Hinkley
@rosshinkley
May 02 2016 19:00
give me a minute....
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:03
I just read about them here but I don't get how they relate to nightmare..
Ross Hinkley
@rosshinkley
May 02 2016 19:05
so... the idea is you can use vo or co to use yield on a thenable, which nightmare is
this comment might be worth a read
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:08
Do I need to know about them to use nightmare?
Ross Hinkley
@rosshinkley
May 02 2016 19:08
you may also want to have a look at nightmare-examples, specifically the vo and co examples
no.
out of the box, you can use .then() and native promises to do most everything you need to do
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:09
Okay.. also, I saw some examples using .wait() with no parameters, but it doesn't say anything about it in the documentation. Do you know what it does?
Ross Hinkley
@rosshinkley
May 02 2016 19:12
uh... i think in the current version, that won't work
i'd be curious where you saw it
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:13
here. It says that it "waits for the whole page to load".
Ross Hinkley
@rosshinkley
May 02 2016 19:14
fwiw, source
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:14
Oh. Okay then, thanks
Ross Hinkley
@rosshinkley
May 02 2016 19:14
ah, yeah,
judging from the date and context, this was on a 1.x version of nightmare
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:15
oh
How would I wait for the whole page to load before continuing, then? is there a selector for the whole page?
Ross Hinkley
@rosshinkley
May 02 2016 19:15
uh, i think .goto() will wait for a page loaded event
but if you want to be super-explicit, you could always do like... .wait('body') or something
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:16
okay, thanks
Ross Hinkley
@rosshinkley
May 02 2016 19:16
np :)
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:16
Nightmare no longer uses JS phantom? I've seen several references to it on (nightmarejs.org), but the docs only mention electron..
Ross Hinkley
@rosshinkley
May 02 2016 19:17
nightmare migrated to electron in 2.0
predates me by a bit :)
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:18
:D k
Ross Hinkley
@rosshinkley
May 02 2016 19:18
you can read about it in segmentio/nightmare#200
or in the history
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:19
cool k thx
Ross Hinkley
@rosshinkley
May 02 2016 19:19
np, let me know if you have any more questions :)
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:19
last question (promise :D) does basic authentication let you "log in" to websites, or should i do that manually with .type and .click ?
Ross Hinkley
@rosshinkley
May 02 2016 19:20
hahaha, don't worry about it
basic auth is for http auth, i think
you'll probably want to type and click yourself
especially if you're testing something you've written. Behaves more like a "real user" that way.
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:23
Okay, then. Oh then that leads to another question (sorry :worried: ) does .wait(selector) wait until the selector exists, or is visible? because i've figured out that the login window always exists, it just becomes visible when you press "log on" (and you can actually log on with javascript without even making it visible).
Or do you recommend just using .type() without bothering to click login ?
Ross Hinkley
@rosshinkley
May 02 2016 19:23
hm...
.wait(selector) waits for existence
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:24
Okay, great, thanks
Ross Hinkley
@rosshinkley
May 02 2016 19:24
that much i can answer
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:24
k
I'll just not bother clicking login at all if i don't have to :P
thanks so much!!
Ross Hinkley
@rosshinkley
May 02 2016 19:24
you can check for visibility with .visible(), but there isn't a builtin way to wait for visibility
but you could certainly write that yourself
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:25
okay, i will. thanks a ton!! :D
Ross Hinkley
@rosshinkley
May 02 2016 19:25
no problem
lmk if you get stuck :)
Maxwell Zhao
@thepiercingarrow
May 02 2016 19:25
k :D
Maxwell Zhao
@thepiercingarrow
May 02 2016 23:51
What does .then do?