Skip to content

Feed aggregator

Headless Browser Testing with CasperJS

Sauce Labs - 3 hours 46 min ago

I must admit, the first time I heard about headless browser testing, I had zero knowledge of the technology. As I started to learn more about headless browser testing and compared it with Selenium, it quickly came to my attention that both are different, and both have different objectives. There is no rivalry or battle; both testing frameworks serve a purpose in your delivery chain.

A headless browser is a web browser without a graphical user interface. Headless browsers provide automated control of a web page in an environment similar to popular web browsers, but are executed via a command line interface or using network communication.1)“Headless browser – Wikipedia, the free encyclopedia.” 2015. 1 Jun. 2016 jQuery("#footnote_plugin_tooltip_9777_1").tooltip({ tip: "#footnote_plugin_tooltip_text_9777_1", tipClass: "footnote_tooltip", effect: "fade", fadeOutSpeed: 100, predelay: 400, position: "top right", relative: true, offset: [10, 10] });

Selenium is a portable software testing framework for web applications. Selenium also provides a record/playback tool for authoring tests without learning a test scripting language.2)“Selenium (software) – Wikipedia, the free encyclopedia.” 2011. 1 Jun. 2016 jQuery("#footnote_plugin_tooltip_9777_2").tooltip({ tip: "#footnote_plugin_tooltip_text_9777_2", tipClass: "footnote_tooltip", effect: "fade", fadeOutSpeed: 100, predelay: 400, position: "top right", relative: true, offset: [10, 10] });

Let’s take a closer look at CasperJS (headless browser testing framework) and how we can add another testing layer to our delivery chain.

What is CasperJS?

CasperJS is a JavaScript scripting and testing framework built on top of PhantomJS (WebKit) and SlimerJS (Gecko). What is a WebKit, and what is Gecko? WebKit is an open source browser engine for rendering web pages in Safari, Chrome, and Opera. Gecko is the Firefox browser engine. The web browser engine renders content such as HTML, XML, images, and formats information (CSS). CasperJS is a testing utility for functional navigation, page status, network monitoring, screen capture, and scraping data off the web page. CasperJS allows assertions, which are an easier way to track failed tests.

Handful of CasperJS Functions To Ease Testing

The CasperJS API has an extensive collection of features available. The most important of the features is the tester module. For one of my recent projects, I wanted a lightweight pre-commit test to check the page HTTP status code after deployment. Calling the assertHttpStatus() function was a perfect testing solution for me. Here is a list of all the CasperJS modules:

ModuleDescription CasperEasy way to create Casper instance and pass Casper options ClientutilsClient-side utilities are injected in the remote DOM environment ColorizerGenerates ANSI color output on the console screen MouseMouse operations like moving, clicking, double-clicking, rollover, etc. TesterUnit and functional testing assertions UtilsSimple helper functions

I highly recommend you check out the online API documentation when evaluating a headless browser testing framework before making your final decision. The CasperJS online documentation is hands-down one of the best-documented testing frameworks out there. Each function has an excellent description with an example.

Writing a Simple HTTP Status Test

To get started, you need to properly install Casper, and then we can write our first page http status code test.

Let’s dive right into it. For the sake of this article, I have initialized the base URL variable and a few arrays for links, page titles, and page by name inside the test file.

var baseUrl = 'http://www.saucelabs.com';

var links = ["/resources",
"/features",
"/our-values",
"/enterprise",];

var saucePageTitles = ["Sauce Labs: Resources",
"Sauce Labs: Features",
"Sauce Labs: Values",
"Sauce Labs: Enterprise-grade testing on Sauce",];

var saucePageByName = ["Resources", "Features", "Company", "Enterprise"];

To keep it simple, the test will execute each element of the array. The function ‘casper.start().repeat(nTimes, function()’ begins to run the test and will repeat (loop) through the test a given number of times. The variable nTimes equals the number of elements in the ‘links’ array (which is 4). Then function ‘casper.thenOpen(baseUrl + links[i], function()’ will open a new location, which in our case is the baseUrl + links[0] (http://saucelabs.com/resources) and execute assertions and screen capture lines of code within the function. Lastly, the most important function ‘casper.run(function()’ runs the whole suite of steps and executes a callback when they’ve all been done. FYI – Casper suite will not run without a ‘run()’ function.

casper.test.begin('Sauce Labs Pages HTTP Status Code', function suite(test) {

var i = 0;
var nTimes = links.length;

casper.start().repeat(nTimes, function() {

casper.thenOpen(baseUrl + links[i], function() {
var status = this.currentHTTPStatus;
var title = this.getTitle();

// Assertions
test.assertTitle(saucePageTitles[i], saucePageByName[i] + ' has the correct title');
test.assertHttpStatus(200,'HTTP Status: ' + status + ' - ' + baseUrl + links[i]);

// Capture the current screen
var currentPageName = saucePageByName[i].toLowerCase();
this.capture('./screenshots/mlb-' + currentPageName + '-pg-httpstatus.png');
console.log('');
i++;
});
});

casper.run(function() {
test.done();
});
});

Now that we have created an HTTP status test, let’s run it.

Run CasperJS Test from Command Line

casperjs test tests/httpstatus.js

Example: Console for SUCCESSFUL Tests

Test file: tests/httpstatus.js
# Sauce Labs Pages HTTP Status Code
PASS Sauce Labs Pages HTTP Status Code (NaN test)
PASS Resources has the correct title
PASS HTTP Status: 200 - http://www.saucelabs.com/resources

PASS Features has the correct title
PASS HTTP Status: 200 - http://www.saucelabs.com/features

PASS Company has the correct title
PASS HTTP Status: 200 - http://www.saucelabs.com/our-values

PASS Enterprise has the correct title
PASS HTTP Status: 200 - http://www.saucelabs.com/enterprise

PASS 8 tests executed in 20.644s, 8 passed, 0 failed, 0 dubious, 0 skipped.

Example: Console for FAILED Test

FAIL Enterprise has the correct title
# type: assertTitle
# file: tests/sauce/httpstatus.js:28
# code: test.assertTitle(saucePageTitles[i], saucePageByName[i] + ' has the correct title');
# subject: "Sauce Labs: Enterprise-grade testing on Sauce"
# expected: "Sauce Labs: Enterprise"
FAIL 7 tests executed in 19.263s, 6 passed, 1 failed, 0 dubious, 0 skipped.

It is easy to see that the console outputs for successful and failed tests are informational. I’ll focus mainly on the failure exception stack trace, which provides enough information on why the CasperJS assertion failed. It clearly identifies that the page title response doesn’t match the expected page title defined inside the test.

Conclusion

The main inspiration behind this article was to help everyone identify that both headless and real browser testing are different. I also wanted to show how simple it is to write an http status test, and show that headless browser testing serves a purpose of everyone in the continuous integration pipeline. It takes a minimal amount of effort to design an acceptance test suite through CasperJS.

Greg Sypolt (@gregsypolt) is a Senior Engineer at Gannett – USA Today Network and co-founder of Quality Element. He is a passionate automation engineer seeking to optimize software development quality, while coaching team members on how to write great automation scripts and helping the testing community become better testers. Greg has spent most of his career working on software quality—concentrating on web browsers, APIs, and mobile. For the past five years, he has focused on the creation and deployment of automated test strategies, frameworks, tools and platforms.

References   [ + ]

1. ↑ “Headless browser – Wikipedia, the free encyclopedia.” 2015. 1 Jun. 2016 2. ↑ “Selenium (software) – Wikipedia, the free encyclopedia.” 2011. 1 Jun. 2016 function footnote_expand_reference_container() { jQuery("#footnote_references_container").show(); jQuery("#footnote_reference_container_collapse_button").text("-"); } function footnote_collapse_reference_container() { jQuery("#footnote_references_container").hide(); jQuery("#footnote_reference_container_collapse_button").text("+"); } function footnote_expand_collapse_reference_container() { if (jQuery("#footnote_references_container").is(":hidden")) { footnote_expand_reference_container(); } else { footnote_collapse_reference_container(); } } function footnote_moveToAnchor(p_str_TargetID) { footnote_expand_reference_container(); var l_obj_Target = jQuery("#" + p_str_TargetID); if(l_obj_Target.length) { jQuery('html, body').animate({ scrollTop: l_obj_Target.offset().top - window.innerHeight/2 }, 1000); } }
Categories: Companies

Where APM Agents Fear to Tread

How important is APM to your organization? Assuming you’re reading this in the 21st century (if not, come back to the future!), the answer is probably pretty important. Your applications are the business. The digital experiences of your customers depend on them, as does the productivity of your employees. And, according to a Gartner Survey […]

The post Where APM Agents Fear to Tread appeared first on about:performance.

Categories: Companies

Test is a Ghetto

Chris McMahon's Blog - 9 hours 7 min ago

If you read software testing news aimed at the general public, you might be of the opinion that software testing is done by, and *properly* done by:
Autistic people with minimal training.
Impoverished Aboriginals with minimal training

Impoverished inner city people with minimal training
People in developing countries with minimal training
The key of course is "minimal training". There is a class of software testers who have minimal programming skills, or system administration skills, or database skills, or any technical computer skills at all. These testers do honorable work and can be valuable members of a software development team. They have been my colleagues; I have helped hire them; and I have trained them in test automation. And I still do that sort of work myself sometimes, although others are better at it than I am.
However, their lack of technical skills mean that they tend to have lower status, lower income, and are often considered fungible, easily swapped out as economy dictates, or replaceable by automation. At least at the start of their careers, these testers can be caught in a vicious circle of not having the technical skills or critical abilities to advance their careers, while also lacking enough understanding of modern software development to see a way to improve their skills. Many stay in this circle indefinitely, where a whole mythology of the value of codified ignorance evolves. This is the software testing ghetto.
Ghettos exclude their occupants from the general discourse, but it is also true that ghettos are exploited by agents of the greater culture. Software testers, particularly junior-level software testers, especially such testers that are because of their circumstances ignorant of modern software development discourse, are especially prone to exploitation. If they are represented by an agent, then someone is paid to recruit them and train them. Someone is paid to negotiate their contracts. Someone sells their employers the tools they have been trained to use.
I have not found out anything about the training that autistic people, Aboriginals, or Malaysians receive; the original draft of this essay was to have provided a detailed analysis of the training provided by Doran Jones, Per Scholas , and Keith Klain in New York City. There is a wealth of material available, and I urge you to search online yourself.
However, in the course of doing that research, I discovered that Doran Jones has sued Keith Klain and Per Scholas for fraud over that software testing training program. The entire document (PDF download link)  is a fascinating look at the inner workings of those agencies that sell software testing services. The part of the lawsuit relevant to the software testing training begins at paragraph 89, for those who wish to read it. Also of interest given the stated list of Per Scholas partners is paragraph 37.
Under the circumstances, and given the nature of the claims against Klain and Per Scholas, I think it is not appropriate for me to publish my comments, but I would like to point out one fact not contained in the lawsuit documentation: the Association for Software Testing committed their resources  to the Per Scholas training program in NYC while Keith Klain was a member of the AST Board of Directors. I expect that the current and recent officers of the AST are extremely interested in the outcome of this lawsuit.
Klain says this about software testers: "Software testing is a strange business. It’s commoditized (sic), devalued, misunderstood, and goes through cycles of being chopped, changed, and lives at the front lines of imminent takeover by our robot overlords. Why anyone would want to be a professional software tester is even harder to understand." Read the whole thing
Interestingly, Klain and the people involved in this Per Scholas project are also the most vocal opponents of software testing certification, sometimes with questionable approaches to gutting certification efforts.
It makes sense that these agents of minimally trained software testers would oppose certification. A global, generally-accepted, inexpensive certification in software testing would allow those entry-level software testers with limited knowledge of modern software development culture to more easily be their own agents in that culture. The market for this sort of exploitation might shrink considerably. In hindsight, I wish I had said this explicitly when I tackled the topic in 2010.  As your career matures, your CV becomes more important than your certifications, but getting certified early on is a perfectly reasonable career move.
As Marlena Compton said in her 2015 essay "A Tableflip Guide: Transitioning from Tester to Developer"  "If you go to a testing conference you’ll find people talking about how you can stay in testing forever and how it is a great career path. I’ve noticed that, often, the testers who shout the loudest about staying in testing forever have carved out their own place in the power structure of the software testing industry." I urge you to read the whole essay.
I'll suggest further that those testers shouting the loudest may also depend on the minimally skilled testing ghetto for their livelihood, and may not have your best interests in mind.
If you as a software tester
are happy with your career path and prospects for growthare happy with the skills you have and the prospects to develop them furtherare respected by everyone on your development team and are treated as a peerrepresent your own interests to your employer with good faith on both sideshave technical training available to youunderstand technical aspects of software development other than testing
then this essay probably does not describe you. If these things are not true for you, you may be in the software testing ghetto.
  
Categories: Blogs

TestTrack Superpower #7: Email Tracking

The Seapine View - 9 hours 9 min ago

Create an Eternal Archive with Email TrackingWhen superheroes go up against a foe they’ve faced before, they turn to their archives to remind themselves of how the battle went last time. TestTrack email tracking is one way you can create your own archive.

Email tracking stores email correspondence as a fully searchable, easily visible part of a TestTrack item, keeping all information related to the item accessible to the team rather than scattered across individual mailboxes.

Get the Ebook

Learn more about email tracking and other superpowers in TestTrack: Champion of Quality!

Over the past 20 years, Seapine has grown into a multi-product company and globally recognized leader in ALM tools. TestTrack has grown, too, from a simple bug tracking tool to a powerful suite of tools that encompass the entire development process.

TestTrack: Champion of Quality shines a spotlight (or Bat Signal, if you will) on 20 powerful features you may not be aware of, even if you’re a longtime user.

Inside this ebook, you’ll learn how TestTrack’s superpowers can help you:

  • Conquer compliance
  • Shine a spotlight on critical data
  • Stand vigilant over change
  • Defeat the Auditor, Scope Creep, and other villains seeking to steal your product quality

And more!

 Champion of Quality

Categories: Companies

Serverless Single Page Apps, In Print at The Pragmatic Bookshelf

Radyology - Ben Rady - 11 hours 8 min ago
I've been working on a book that explains the style of single page app that I've been building for the last few years. Up until very recently, I couldn't find a way to use this style for public-facing apps, because... Ben Rady
Categories: Blogs

Webinar Follow-up: New Testing Battlefields

Telerik TestStudio - 16 hours 52 min ago
Four testing experts recently explored testing beyond the "traditional" desktop and web, including the new battlefields of Mobile and IoT. Read on for a recap or to watch a webinar replay. 2016-06-21T12:20:00Z 2016-06-30T07:45:33Z Jim Holmes
Categories: Companies

Are You Ready for the New Testing Battlefields?

Telerik TestStudio - 16 hours 52 min ago
A software-defined way of living and the digital transformation of traditional businesses are not the future. They are already here. This brings challenges to testers and developers alike. Join this one-hour roundtable discussion with industry experts to hear what’s new in testing today. 2016-06-13T15:20:23Z 2016-06-30T07:45:33Z Antonia Bozhkova
Categories: Companies

Meet Jim Holmes: Developer Expert for Test Studio

Telerik TestStudio - 16 hours 52 min ago
Jim Holmes, Telerik Developer Expert for Test Studio and Kendo UI, talks about software development in the enterprise. 2016-05-18T18:30:37Z 2016-06-30T07:45:33Z Jen Looper
Categories: Companies

Telerik and Testdroid Webinar Bonus Q&A

Telerik TestStudio - 16 hours 52 min ago
In this blog, Ville-Veikko Helppi tackles some of the unanswered questions from the webinar. 2016-06-06T14:55:06Z 2016-06-30T07:45:33Z Ville-Veikko Helppi
Categories: Companies

A Powerful Case Study on Telerik Analytics: Test Studio

Telerik TestStudio - 16 hours 52 min ago
Telerik Analytics provides powerful tools to help you make data-driven decisions to improve and grow your product. Learn how we used analytics to improve our own software, Test Studio. 2016-06-03T15:46:07Z 2016-06-30T07:45:33Z Gaurav Verma
Categories: Companies

Telerik and Testdroid—Real Device Testing Made Easy

Telerik TestStudio - 16 hours 52 min ago
To deliver high-quality mobile applications, testing is critical. Fortunately, Telerik Test Studio and Bitbar have your back. Hop on this one-hour webinar to learn how Test Studio and Bitbar Testdroid Cloud have joined forces to offer you a comprehensive and intuitive real device testing experience. 2016-05-03T12:30:00Z 2016-06-30T07:45:33Z Antonia Bozhkova
Categories: Companies

Test Studio Web and Desktop R1 2016 Updates

Telerik TestStudio - 16 hours 52 min ago
The latest release of Test Studio is here with major updates across the board, including improved coding UX, to help you test your apps more easily than ever. 2016-04-22T19:14:55Z 2016-06-30T07:45:33Z Konstantin Petkov
Categories: Companies

Recapping the Test Studio 2016 R1 Release Webinar

Telerik TestStudio - 16 hours 52 min ago
During the latest Test Studio 2016 R1 release webinar you all asked some very good questions that were right on target. Let's recap the webinar with some Q&A. 2016-04-14T15:29:32Z 2016-06-30T07:45:33Z Iliyan Panchev
Categories: Companies

How We Test Software: Chapter Two—Telerik Platform

Telerik TestStudio - 16 hours 52 min ago
Have you wondered how the teams working on Telerik products test software? We continue with the next chapter in our detailed guide, giving you deeper insight into our very own processes. This chapter focuses on Telerik Platform. 2016-04-11T21:07:02Z 2016-06-30T07:45:33Z Angel Tsvetkov
Categories: Companies

Let the New Test Studio Turn You Into a Mobile Testing Hero

Telerik TestStudio - 16 hours 52 min ago
The first major Test Studio product update for this year is now live. Go grab your free evaluation copy, and keep on reading to learn what’s new, including enriched mobile testing with support for web apps and more. 2016-04-01T15:08:05Z 2016-06-30T07:45:33Z Antonia Bozhkova
Categories: Companies

How Our Telerik Teams Test Software: Chapter One

Telerik TestStudio - 16 hours 52 min ago
Have you wondered how the teams working on Telerik products test software? Today we launch a detailed guide, giving you deeper insight into our very own processes. 2016-03-22T14:34:15Z 2016-06-30T07:45:33Z Daniel Djambov
Categories: Companies

Telerik Test Studio and Selenium

Telerik TestStudio - 16 hours 52 min ago
Mixing different frameworks into one automated testing solution can lead to powerful results. Test Studio and Selenium are two frameworks that complement each other well. 2016-03-18T15:46:17Z 2016-06-30T07:45:33Z Iliyan Panchev
Categories: Companies

Product Notifications in Test Studio

Telerik TestStudio - 16 hours 52 min ago
With Product Notifications, Test Studio becomes easier to use than ever, helping you discover new functionality and save time. 2016-02-11T16:02:11Z 2016-06-30T07:45:33Z Konstantin Petkov
Categories: Companies

Looking Back and Ahead as We Recap the Test Studio Webinar

Telerik TestStudio - 16 hours 52 min ago
The latest updates to Telerik Test Studio have arrived. We recap what's new and upcoming here, which we also recently discussed in our webinar (which you can watch here). 2016-02-09T17:23:21Z 2016-06-30T07:45:33Z Iliyan Panchev
Categories: Companies

Looking Back and Ahead at the Telerik Test Studio Webinar

Telerik TestStudio - 16 hours 52 min ago
The latest updates from Test Studio are here, adding more mobile features and other enhancements. Learn about what’s new in an upcoming webinar. 2016-01-22T17:21:44Z 2016-06-30T07:45:33Z Antonia Bozhkova
Categories: Companies

Knowledge Sharing

SpiraTest is the most powerful and affordable test management solution on the market today