Magento functional testing with casper.js

Posted in Magento upgrades on November 3, 2013 0 comment(s)  

Testing can be boring and time consuming task. So why don’t we use some tools and make our lives easier? In Magento there are numerous “boring” tasks that need to be done after the first install and then again when you test a new functionality. For example, create a test account, add product to cart, go trough checkout process, add product to wishlist, compare etc.Casper.js seems like the right tool for these “repeated” tasks. So, what is casper.js!?

Magento functional testing with casper.js

CasperJS is an open source navigation scripting & testing utility written in Javascript for the PhantomJS WebKit headless browser and SlimerJS (Gecko). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks

We will skip the installation process as it is very straightforward. So let’s jump into testing right away.

We will create two scenarios for demo purpose

Scenario 1

Open home page of your Magento store, click on log in link, open “Login or Create An Account” Magento page, find the “Create an Account” button and click on it to open “Create an Account” page, fill out the form, submit it, wait to be redirected to My Account dashboard and then find inside the body text “Hello, First name Last name!”.

And here is the test:

magento functional testing

Scenario 2

Open your store home page, fill out the search form with term “sony”, search for products, on search results page select the first product, open it, add it to cart, wait for the shopping cart page to fully load and take a screenshot.

Test:

magento functional testing

Now to run tests we simply run this command:

magento functional testing
magento functional testing

Run test

And here is the screenshot:

magento functional testing

Screenshot as a result

So at the end of the day (and this blog post) you can now write simple tests or you can automate some of the daily basic process while working with Magento.

Hope you’ll find this useful and happy testing!

From: Inchoo.net


This post was posted in Magento upgrades

Leave a comments
Your email address will not published. Required fields are marked *

What Our Clients Say?

  • Oscar Soto MANAGER
    ArrowHiTech has always impressed me! They are professionals and are quick to response to my needs. I have used
    them in the past and will continue to use them in the future. Thanks Martin and all the Staff at ArrowHiTech!!!
  • The guys of AHT solutions did a perfect job and are real profesionals. Definitely recommend them and will use them again!
  • Jonatas Leonel MANAGER
    Martin has a great team of Magento experts, I really liked the work he did for me. I asked him to customize my template following a couple of jpg files that I got from a designer and he worked on that template without the psd's - that was awesome, the result I got was really good.
  • I really enjoy working with ahtsolutions. Quick response to our questions, delivery the project in time and excellent skills. I hope to work with them soon
Request us now! Yahoo:gravitational_boy Email:info@mage-shop.com Skype:hyun_yoo_it +84437955813