These are chat archives for rosshinkley/nightmare

7th
Apr 2017
Roy
@iroy2000
Apr 07 2017 01:11
I'm trying to test an auto-suggest component, I'm able to put search text, I see the "results" shows up very quick, but I can't get the item from the result set , I'm using material-ui
.type('.searchInput input', 'teach')
.wait('.searchResult') // timeout here
johnferro
@johnferro
Apr 07 2017 14:02
@iroy2000 Does the timeout happen after the 30s default? (https://github.com/segmentio/nightmare/#waittimeout-default-30s)
Roy
@iroy2000
Apr 07 2017 15:47
@johnferro yes, I also set the timeout explicitly to 30s
Not sure if it is because of the async nature ? I put in keywords, the client will send an ajax call, and it return the result, and it display the result. I can see the result is displayed and disappeared very quickly. Another question, does the nigthmareJS has something like "keepFocus()" on element?
johnferro
@johnferro
Apr 07 2017 18:14
@iroy2000 Ah ok, from that description it definitely sounds like the element is gone before the wait check is performed causing it to wait indefinitely. The type action does blur the element after the typing is finished so that is probably the issue. I don't think there's a supplied function to focus but you can use an evaluate function and doing something like the following in it - https://github.com/segmentio/nightmare/blob/a835558067c0dd72b5b10c14613d9071aef39d13/lib/actions.js#L178 - if that would cause the results to show up again. Otherwise you can look at how the type action is implemented (https://github.com/segmentio/nightmare/blob/a835558067c0dd72b5b10c14613d9071aef39d13/lib/actions.js#L202) and create your own action to do something similar while keeping focus at the end
Roy
@iroy2000
Apr 07 2017 20:20
Thanks @johnferro I will look into that.
navamgupta
@navamgupta
Apr 07 2017 22:49
Hey @johnferro this is Navam, I work with Roy :). I have a followup question on the conversation you guys just had about the type action. Do you know why we do the blur after every type, are there scenarios which actually need this functionality?