Flash Object Automation using Selenium

Testing Tools – Test Execution
If you work in web application testing, you probably know that Selenium is one of the best tool for automating web applications. Though it can be used to test various aspects of web application, sometime you need to find your way around when using Selenium, one such situation is testing flash component using Selenium. Developers use Flash to beautify their websites, but it makes test automation a challenging task because Selenium can not read or record any actions on flash objects.
There are two main issues that needs to be addressed while automating web applications involving flash objects -
Verifying a certain value is set or it exists or not or in simple terms you need to ‘get’ certain properties of the object and compare it against your benchmarks
Performing actions on an object or ‘set’ certain values.
These two issues could easily be handled by Selenium for most of the website objects except for Flash.
In this article we will describe how to automate testing of Flash based components of web applications. The basic steps involved in any automation are:
Observe and analyse
Draw a common pattern
Use this pattern for automation.
These three steps are very important while understanding the automation of Flash based components for web applications . Most of the time Flash is used in the web applications for -
To play static content in the form of movie. The reason I am saying static content is that the contents of the movie stay the same.
To render the dynamic contents using Flash such as rendering the contents for a strip of images or a strip of clips using Flash or displaying the title of any page using Flash. The reason I am mentioning these as dynamic content , is that Flash is just picking up this data from some system and displaying it in the Flash format. The contents may vary depending on the context of the page. For example, Flash can be used to display the a strip of pictures uploaded for a particular program for a media website. In this case the behaviour of the Flash is the same for all the programmes, only the content it is displaying is changing.
Both these cases could be automated in a different manner depending upon the information available in the DOM (Document Object Model). We are going to take second case first and explain how we used the DOM information for our automation and addressed one of the two issues (i.e. verifying a certain values). We used the 3 steps mentioned earlier for automating the Flash based component of a media website. If you have a website where dynamic Flash information is read in ‘flashvars’ then you could also follow the same steps.
So how do you know whether the Flash components of your website are using the ‘flashvars’ information or not? Well its not that difficult to find it out. All you need to do is:
Install firebug plugin for Firefox, if you do not have it already.
Search for the ‘flash’ in the firebug you will get some div tag informing about the flash content and containing an object tag for the flashplayer.
In this object tag search for ‘param’ mostly it is called ‘flashvars’ and the value contains all the information that flash will display.
Alternatively you could search directly for ‘flashvars’ :) As displayed below
Looking at this you could easily get its xpath ( just browse you mouse over the element displayed on top of firebug near edit) or use another Firefox plugin, XPath checker.
After having the xpath you could get the value of this ‘param’ or ‘flashvars’ in a string using getattribute() function of Selenium.
This string would appear a bit strange on first look but on analyzing this string you would find a common pattern and it would be easy for you to then parse this string to get the required values.
This technique is very useful in at least verifying certain values. you could always search for ‘flash’ in the firebug and see if there is any information in its parameters or other tags that could be exploited for automation. Let us apply this technique on www.youtube.com because we know all the videos on you tube are displayed through Flash. A very interesting case of applying this technique could be testing whether the id of the video played on youtube is the same as the one displayed for embedding or not. Here is the screen grab of a random video on youtube.
As you can see we have followed the same steps mentioned in this article and searched for ‘flashvars’ we found that flashvars contains some words as ‘video_id’ in the string and then after the ‘=’ sign it contains the value of the id. Yes we got it we could parse this string for value of ‘video_id’ and compare it with the value specified in the url !!!
In the technique presented above, there is nothing which is only applicable for only Flash objects. You can follow the three steps mentioned above for any kind of automation and might come up with similar technique for something else as well based on your context. In the next article we will discuss a Flash specific technique for the Selenium using flash-selenium.jar to automate more advanced interactions with Flash using Selenium.

Software Testing Myths


Any IT professional is sure to know the different phases of the Software Development Life Cycle or SDLC, namely Feasibility Study, Requirement Analysis, Design, Construction or Coding, Testing, Implementation, Maintenance & Support - the activities carried out in each phase & their significance. But, very few agree on the importance of Software Testing phase.

“Software implementation is a cozy bonfire, warm, bright, a bustle of comforting concrete activity. But beyond the flames is an immense zone of darkness. Testing is the exploration of this darkness.” - extracted from the 1992 Software Maintenance Technology Reference Guide

Testing is often considered as a thankless job.

While developers say with pride: "Wow!! My code is running in production", testers usually don’t say "Wow!! The code that I tested is running in production"!!! This attitude can also be justified if we consider some examples of the usual talk that goes on among colleagues/peers/friends in the IT circle, like:

Mr. A: Which project are you working on?
Mr. B (Tester): Currently. I'm in a Testing project.
Mr. A: Oh...Umm...OK...
Mr. A: Mr. C, how about you?
Mr. C (Programmer/Developer): A Development & Maintenance project
Mr. A: Oohh?? What technology? Which platform? What’s the project all about?? … And so on

Even though there's no denying the fact that Construction/Coding is a very significant phase in the life cycle of any software product, the role of Testing as an activity should be given its due importance, because of the main reason, among others, that its the phase of SDLC just before a software product goes to production; i.e.; when your software product/application actually starts functioning in real world.

Therefore, it’s the only phase where you can ensure & gain a reasonable level of confidence that that you are delivering quality products to the customer.
This does not mean that quality assurance starts in the Testing phase. Ensuring & Maintaining quality is a continuous process which should be practiced right from Day 1 of the SDLC cycle.
In other words, during testing phase, you can "bang" your product in different ways, by which I refer to different kinds of testing like functional testing, stress testing, performance testing & so on, and validate whether the software product works fine.

Needless to say, delivering quality software delights customers & helps in getting more business. That said about the importance of Testing, we will now proceed to look into some perceptions or “myths” about software testing which prevails, in general, among the IT community

Testing is done to demonstrate that there are no errors/bugs/defects in the software product being developed

No. Not at all!! Though this is one way of conveying the meaning, it takes us away from
the main objective of testing

Testing is the process of uncovering defects... The objective of any tester should be to
try his best to crack the code. This should not be seen as a destructive activity which points fingers at or find faults with the developers. In fact, testing should be considered as a healthy feedback mechanism to the developer community so that they can make maximum use of the defects found during testing, analyze them, find the root cause & devise appropriate preventive mechanisms. Actually, the defects found during testing helps improving the quality of the code!

A tester should never work under the assumption that the system works!! The software product should be tested with the intent of finding errors. The test, which when executed reveals a defect in the software, is a success. Though Testing, by itself, does not improve the quality of the software product, it is an indicator of the quality. Rather that considering Testing
as a separate phase in the SDLC, it should be an activity which is integrated into each & every phase. The intent should be to Analyze & Test, Design & Test, Develop & Test, Fix Defects & Test more...!!

Testing is done to ensure that the software/application does what it is supposed to do

True enough!! But it’s not just that...The software should also not do what it is not supposed to do. Good test cases are the only way to establish a reasonable level of confidence on the software product. The Tester should think of all possible scenarios based upon the test requirements or test plan. Though there are various methods to prepare a large number of test cases like Equivalence Partioning, Boundary Value Analysis and so on, a lot depends on one's own intuition to come up with some good cases which reveals defects in the software

Testing is easy...!!!

Sometime back, I conducted a short class on Software Testing to a group of new recruits. While we were discussing about different type of projects, one participant said that he is very interested in a testing career. When asked the reason for his interest, prompt came the answer: “Testing is very easy, that’s why!!” This holds good only in some situations.

Though it’s simple to prepare straightforward test cases, at times testing can be a real challenging task.

Any production issues will, in many cases, backfire first to the testing teams. Why was this scenario not covered in the test plan??

Therefore, a Tester should develop the capability to look or think beyond the requirements mentioned in the test plan or specifications.

This is very important in case of System Testers who are responsible for ensuring that the software product works appropriately from "end-to-end ".

Testing does not offer any opportunities for career growth.

There are a wide range of roles that one can take up, if opting for a Testing career.
Pursuing a testing career offers more scope for improving Business/Domain knowledge.
It enables one to adopt a holistic approach of the entire software system instead of concentrating on just a unit or module.

A good number of testing certifications are offered by reputed institutes, which helps you attain a strong foundation in this career path.

This does not mean that you don’t have all these opportunities at all if you are a Developer.
It can be said that a Testing career has its own plus points. It entirely depends on one's own interests!

Testers do not perform well in development projects (or Testers are poor in coding)

Tester or not, the expertise on developing quality code depends upon one's own programming skills and constant or continuous learning in that area.
Some people, though in testing projects, take time out of their work to improve their programming skills by contributing to coding efforts or taking up projects voluntarily.

Thus, being a Tester does not prevent you in any way from being an expert Programmer or Vice Versa!!!

One way to narrow the communication gap between Tester & Developer community is to include the Testing teams, right from the Requirements/Design Stage meetings so that everyone involved in the life cycle of developing a software product can take part in the discussion & offer valuable suggestions.

This is evident from the below lines, which wonderfully describes the importance of Testing

More than the act of testing, the act of designing tests is one of the best bug preventers known. The thinking that must be done to create a useful test can discover and eliminate bugs before they are coded - indeed, test-design thinking can discover and eliminate bugs at every stage in the creation of software, from conception to specification, to design, coding and the rest. -Boris Beizer, Software Testing Techniques, "Creating a Software Engineering Culture" by Karl Eugene Wiegers"

No formal training is needed to work in a Testing project... Anyone can be a Tester!

True enough, anyone can be a Tester...but, only a good Tester can come up with quality Test cases (just like how an expert Developer can write quality Code).
It is essential that proper training is imparted to everyone joining Testing projects. This would not only helps one to understand the importance of Testing, but also tune one's mind to the requirements of becoming a good Tester, which would greatly contribute to a good career in Testing