Menu Close
    Hire us Request quote Reading list Switch to dark mode

    How to sign up in Opencart using CasperJS

    As a user, registering for websites is no fun. Because it’s on a computer, it’s only slightly less annoying than filling out paper forms. Most of the time, all you want is automate our work. If you haven’t heard of “CasperJS” you just might be living in an old era.

    CasperJS eases the process of defining a full navigation scenario and provides useful high-level functions and methods. You can automate the signup process for Opencart using CasperJS. You can learn how to install casperJS from this link http://webkul.com/blog/functional-testing-casperjs/

    By default, a Casper instance won’t print anything to the console. This can be very frustrating when creating or debugging scripts, so a good practice is to always start coding a script using these settings:


    Using verbose setting you’ll be able to trace every step made.

    Here is the script that will explain the signup process. Firstly, we will retrieve the current page title using getTitle(). After that we will wait until an element matching the provided selector expression exists in DOM to process next step using waitForSelector().


    To fill in a form we will use the fill() method.


    After filling the signup form, we will submit the form. Here we use then() and click() methods. then() method is the standard way to add a new navigation step by providing a simple function. You can add as many steps as you need. click() method performs a click on the element matching the provided selector expression.


    The site may take some time to parse your script and render the views. Therefore, we will use wait() method. After waiting 2000 milliseconds we fill out the form.


    Finally, we will run the test.


    Here’s the full code:


    After preparing the script, you have to execute the command in terminal. Here is the command.


    Here, OcSignup.js is the js file in which we have written script for sign up process.You can see the output of the above code in terminal.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again
    Close