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:
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 -
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:
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
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.
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.
0 comments:
Post a Comment