-1

I'm having a hard time finding any information on creating a basic HTML page from which I can start my Cypress tests. I want to create a simple page with a few options/buttons for running different Cypress tests I have developed. Has someone did this before or have any info about it?

The HTML I have so far is:

<!DOCTYPE html> 
<html>   
    <head>     
        <title>Cypress Runner</title>   
    </head>   
    <body>     
        <p>Test 1</p>     
        <button onclick="runner()">Run</button>     
        <script>       
            function runner() 
            {         
                // execute command "npx cypress run";       
            }     
         </script>   
    </body> 
</html> 
7
  • This sounds more like web development question. Perhaps StackOverflow would be a better choice. However, I recommend asking a concrete question when you are stuck on something particular, the question now seems too general to be answered on SO. Another point of view - why do you want to do it? Cypress checks could be easily run from a console, or a pipeline, which are more common use cases.
    – pavelsaman
    Oct 25 at 12:32
  • Thanks for your reply. I will try also SO, but I'm not sure what specifics should I add. I need this so people without technical knowledge can run them. Oct 25 at 12:37
  • Your current implementation (minimal reproducible example) and where it does not work and what you have tried to solve it.
    – pavelsaman
    Oct 25 at 12:38
  • This is the only code i wrote so far: <!DOCTYPE html> <html> <head> <title>Cypress Runner</title> </head> <body> <p>Test 1</p> <button onclick="runner()">Run</button> <script> function runner() { // execute command "npx cypress run"; } </script> </body> </html> Oct 25 at 13:02
  • Have you tried using a test site for this purpose? the-internet.herokuapp.com is often used to practice test automation.
    – Lee Jensen
    Oct 25 at 14:40
1
  • you won't be able to execute Cypress directly from the browser using exec (that is, with only HTML and JS without a backend)...
  • You could, however, have your page send requests to a Node backend, and have that backend run Cypress - using exec is a way to do that, but you can also use Cypress as a Node module, which should be cleaner.
  • That said, if what you need is just a list of your tests and the ability to click to run them, that's already what the Cypress GUI does when you execute it with npx cypress open instead of npx cypress run. See here for the launch options.
1
  • Thank you for your answer, it really helped! Finally I decided to stick to sorry-cypress, so I can deploy my own dashboard in some cloud. Oct 27 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.