These are chat archives for rosshinkley/nightmare

11th
Aug 2016
doArcanjo
@doArcanjo
Aug 11 2016 13:06
@rosshinkley Hi guys! I'm having an issue : after login on the initial page trying to to click the element on a different page fails
doArcanjo
@doArcanjo
Aug 11 2016 13:20
@Mr0grog @rosshinkley @mingsterism
const Nightmare=require('nightmare');

var nightmare=Nightmare({
    waitTimeout:6000,
    openDevTools:{
        mode:'detach'
    },
    show: true
});

var html_element="#a_element_inside_li_with_id";

nightmare
    .goto('http://client-site-here.com/aaa')
    .html("client-site-initial.html",'HTMLOnly')
    .type('input[id="username"]','admin')    
    .type('input[id="password"]','sup_ImAdmin')    
    .click('input[id="inserir"][type=submit]')
    .title()


.then(function (result_initial_page) {
     console.log('result_initial_page',result_initial_page)
})
.then(function (result) {
    return nightmare
    .wait(html_element)
    .html("client-page-after-login.html",'HTMLOnly')
    .click(html_element)
})
Ross Hinkley
@rosshinkley
Aug 11 2016 13:26
what's failing? do you get an error?
doArcanjo
@doArcanjo
Aug 11 2016 13:26
yes
i do
Thank you
Ross Hinkley
@rosshinkley
Aug 11 2016 13:27
what does the error say?
doArcanjo
@doArcanjo
Aug 11 2016 13:28
it hangs
Ross Hinkley
@rosshinkley
Aug 11 2016 13:29
you might want to try adding a .catch() to the end of your .then() chain
(i suspect html_element might not exist)
doArcanjo
@doArcanjo
Aug 11 2016 13:30
but it is present on client-page-after-login.html
Ross Hinkley
@rosshinkley
Aug 11 2016 13:30
(or may never exist, giving your script a second look on a real screen)
doArcanjo
@doArcanjo
Aug 11 2016 13:31
if i change the wait(html_elem) for wait(3000)
Ross Hinkley
@rosshinkley
Aug 11 2016 13:32
is the client-page-after-login.html file getting saved, then?
doArcanjo
@doArcanjo
Aug 11 2016 13:32
on developer tools has error module.js:144 Uncaught TypeError: JSON.stringify is not a function
yes they are (both .html("client-site-initial.html",'HTMLOnly') and .html("client-page-after-login.html",'HTMLOnly'))
Ross Hinkley
@rosshinkley
Aug 11 2016 13:34
is the last .click() call happening?
doArcanjo
@doArcanjo
Aug 11 2016 13:35
no it hangs
if i call it evaluate same thing
Ross Hinkley
@rosshinkley
Aug 11 2016 13:36
hm...
doArcanjo
@doArcanjo
Aug 11 2016 13:36
Thank you again for help
<li><a class="returnFalse" href="">Administração</a>

                                    <ul>
                          <li ><a  id="ut_config_utilizadores"  href="">Configuração de Utilizadores</a>
                           </li>
                                                       <li class="divider"><a  id="backup_homes"  href="">Backup</a>
                           </li>
                                                       <li class="divider"><a  id="logs_aplicacao"  href="">Logs</a>
                           </li>
                   </ul>
the element i want to click is the one with id="backup_homes"
Ross Hinkley
@rosshinkley
Aug 11 2016 13:39
stupid question: do you have another .then() after the last .then()?
doArcanjo
@doArcanjo
Aug 11 2016 13:41
i do several
Ross Hinkley
@rosshinkley
Aug 11 2016 13:41
might be worthwhile to run with DEBUG to see if that yields anything useful... your comment about JSON.stringify bothers me a little
or like i said, a .catch() to see if an error is cropping up...
doArcanjo
@doArcanjo
Aug 11 2016 13:43
im running with the debug
Ross Hinkley
@rosshinkley
Aug 11 2016 13:47
.... and?
doArcanjo
@doArcanjo
Aug 11 2016 13:49
 nightmare queueing action "wait" +4s
  nightmare queueing action "html" +3ms
  nightmare queueing action "click" +4ms
  nightmare running +3ms
  nightmare electron child process exited with code 0: success! +29s
Ross Hinkley
@rosshinkley
Aug 11 2016 13:49
o_O
doArcanjo
@doArcanjo
Aug 11 2016 13:50
I have to terminate the process because it does not trigger the click
if however i change the wait to use a timeout instead an element it throws that JSON error @ developer tools
the element i want is available in document.querySelector("#backup_homes")
on developper tools
Ross Hinkley
@rosshinkley
Aug 11 2016 13:58
hm. i've never seen nightmare stop running like that
and off the top of my head... i can't think of a cause
doArcanjo
@doArcanjo
Aug 11 2016 13:59
hmmm
can i create a gist for you to try
Ross Hinkley
@rosshinkley
Aug 11 2016 14:00
sure, that'd be helpful
i have to leave for the moment, though, but i will be back