Forum Discussion

karmaTrinlema's avatar
karmaTrinlema
Occasional Contributor
4 years ago
Solved

failing cucumber test: not detecting flash message

I have a surprisingly simple cucumber scenario for a rails 4 app that isn't passing.  I am checking that a flash message got set, and this test fails when I run cucumber.  However, it is all correct, set, appearing, etc. when I run it live.  I could really use some insight about what might be happening.

THANKS!

  • Hi,

     

    This works for me....

    import groovy.json.JsonSlurper
    import java.io.File;
    
    def resp = context.expand( '${Some Request#Response}' ).toString();
    def response = new JsonSlurper().parseText(resp);
    
    log.info(response.toString());
    
    // I'm on Windows, escape the double backslash
    File myFile = new File("c:\\Temp\\json2.json");
    
    // Reponse might 'log', but its not a string.  Stringify it.
    myFile.write(response.toString());

3 Replies

  • Do you have the possibility to take a screenshot when the test is failing?

    Do you have the possibility to execute your test not in headless mode, to freeze it, and to check the DOM?

    • karmaTrinlema's avatar
      karmaTrinlema
      Occasional Contributor

      What I found out is that I have to check the flash message first because it is ephemeral.  I was checking which page I was on first.  I re-ran the test with put page.body and saw that when I swapped the order of the tests, I could see the flash message. 

       

      Thank you for your help.