Improving the Selenium include extension
Update: WordPress has altered how the code tags function, making this post very confusing and difficult to read. I’ve replace the code tags and so, even though it’s not pretty, it’s at least readable.
My current client is working with Selenium to automate their acceptance testing. Selenium is an open source tool javascript framework for testing web applications. From the OpenQA website [1]:
"Selenium uses a unique mechanism which allows it to run on multiple platforms. Installed with your application webserver, Selenium automatically deploys its JavaScript automation engine — the Browser Bot — to your browser when you point it at the Selenium install point on your webserver. Thus, you must have write access to the machine your web application server is running on to install Selenium."
-OpenQA.Org
The team started with Selenium about two months ago and have been adding tests on a consistent basis. They currently have a regression suite that takes over an hour to complete. Selenium is a great tool and has definitely help improve the quality of the product that's being delivered by the team.
Ai Li (JEE guru, javascript guru and Selenium hacker) is one of several very talented people that I'm currently working with. She's responsible for a number of tests in the regression suite. As part of her work with Selenium, Ai Li improved the performance of the ‘include’ extension by adding a cache. Here’s the orgininal code form the ‘include’ extension [2]:
var includeCmdRow = PageBot.prototype.locateElementByXPath(xpathExpr, testDocument);
if (!includeCmdRow)
{
return
}
Ai Li replaced the above code with the following:
//first try to retrieve the include from cache
var includeCmdRow = includeFiles[filePK];
if (includeCmdRow == undefined || includeCmdRow == null)
{
var includeCurrentCommandRow = inputTableRows[currentCommandRow];
includeCmdRow = includeCurrentCommandRow;
if (includeCmdRow == undefined || includeCmdRow == null) {
return;
} else {
//store the new include file in the cache
includeFiles[filePK] = includeCmdRow;
}
} else {
//don't have to proceed since the file is in the cached
return;
}
I think this is a great enhancement because it works so well; Selenium is visibly faster. Here’s the complete post by Ai Li on the OpenQA.org forums: http://forums.openqa.org/thread.jspa?threadID=1600
![]()
References
[1] http://www.openqa.org/
[2] http://wiki.openqa.org/display/SEL/include
Can you please tell me how to call a CSV file and a normal file in my selenium script?
Please help me.