tag:blogger.com,1999:blog-75854888028779106572024-03-15T18:09:18.482-07:00Selenium GalaxyNotes automation technologyJerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.comBlogger27125tag:blogger.com,1999:blog-7585488802877910657.post-87551226319614506742009-01-13T21:27:00.000-08:002009-01-13T21:50:54.489-08:00Selenium IDE include command for templateThere is a useful extension for Selenium-Core: include, which can add the content of another test to the current test. Then it is possible to reuse test scripts for Selenese. See OpenQA wiki: <a href="http://wiki.openqa.org/display/SEL/include">http://wiki.openqa.org/display/SEL/include</a><br><br>
However, it supported Selenium-Core only. Many Selenium-IDE users also want to use this feature. So I've ported the existing include extension to work in Selenium IDE. I added it to wiki: <a href="http://wiki.openqa.org/pages/viewpageattachments.action?pageId=283">http://wiki.openqa.org/pages/viewpageattachments.action?pageId=283</a><br><br>
<li>target receives the page address (relative path from base url or use absolute path)</li>
<li>text receives vars names and their values for this test as a comma separated list of var_name=value</li>
<br><br>
include step run in Selenium-IDE looks like:<br>
<a href="http://4.bp.blogspot.com/_2XGzavgWfJk/SW16FAbMAtI/AAAAAAAAABw/VjrJPkkIVlI/s1600-h/includeInIde.PNG"><img style="cursor:pointer; cursor:hand;width: 251px; height: 320px;" src="http://4.bp.blogspot.com/_2XGzavgWfJk/SW16FAbMAtI/AAAAAAAAABw/VjrJPkkIVlI/s320/includeInIde.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5291019363662168786" /></a>
<br>
Please set user-extension.js path for SeleniumIDE->options->Selenium Core ExtensionsJerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com19tag:blogger.com,1999:blog-7585488802877910657.post-18890900306710691402009-01-03T22:33:00.000-08:002009-01-03T23:03:44.306-08:00Remember Certificate Exception extension for Firefox3I submit a new add-on for Firefox3: Remember Certificate Exception.<br>
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_2XGzavgWfJk/SWBZWWkuMSI/AAAAAAAAABY/Jy7e0eTDbPk/s1600-h/rce.png"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 64px; height: 64px;" src="http://2.bp.blogspot.com/_2XGzavgWfJk/SWBZWWkuMSI/AAAAAAAAABY/Jy7e0eTDbPk/s320/rce.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5287324203084558626" /></a>
<a href="https://addons.mozilla.org/en-US/firefox/addon/10246">https://addons.mozilla.org/en-US/firefox/addon/10246</a>
<br><br><br><br>
RCE.xpi features:<br>
Auto complete Firefox3 SSL certificate exception override on exceptionDialog.<br>
Firefox3 introduced new 'Add Exception/BadCert Override' mandatory operations to bypass bad certificate exception.<br>
It is much safer but inconvenient to do mass bypassing while doing development with self-signed certificates.<br>
User wants a tool to auto complete add exception/badcert override operations.<br>
RCE extension is a such kind robot which can:<br>
- auto-click 'Or you can add an exception' link<br>
- auto-click 'Add Exception' button<br>
- auto-click 'Get Certificate' button<br>
- auto-click 'Confirm Security Exception' button<br>
- auto-reload ssl page<br>
The idea of RCE.xpi came from solving my Selenium web automation testing ssl page blocking issue.<br>
Please try badcert demo URLs inside <a href="http://kuix.de/mozilla/certwarndiscussion/proposal20061016/">http://kuix.de/mozilla/certwarndiscussion/proposal20061016/</a> with RCE extension.<br>
Please read firefox3 security topic: <a href="http://www.smop.co.uk/blog/index.php/2008/03/25/firefox-3-security-madness/">http://www.smop.co.uk/blog/index.php/2008/03/25/firefox-3-security-madness/</a><br>
WARNING: please disable RCE when you are going to browse untrusted websites to avoid phishing and mal-ware.<br><br>
Screenshot:<br>
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://addons.mozilla.org/en-US/firefox/images/t/28542/1230996042"><img style="cursor:pointer; cursor:hand;width: 200px; height: 119px;" src="https://addons.mozilla.org/en-US/firefox/images/t/28542/1230996042" border="0" alt="" /></a>
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://addons.mozilla.org/en-US/firefox/images/t/28543/1230996183"><img style="cursor:pointer; cursor:hand;width: 149px; height: 150px;" src="https://addons.mozilla.org/en-US/firefox/images/t/28543/1230996183" border="0" alt="" /></a>
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://addons.mozilla.org/en-US/firefox/images/t/28544/1230996342"><img style="cursor:pointer; cursor:hand;width: 200px; height: 140px;" src="https://addons.mozilla.org/en-US/firefox/images/t/28544/1230996342" border="0" alt="" /></a>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com27tag:blogger.com,1999:blog-7585488802877910657.post-85724649890464383222009-01-02T21:47:00.000-08:002009-01-03T23:40:20.191-08:00Selenium1.0beta for Firefox3 is readyWe have fixed most of <a href="http://sejq.blogspot.com/2008/12/selenium10b-buglist-for-firefox-3.html">blocking bugs</a> on Firefox3. It's time to upgrade our Selenium lab machines to Firefox3.0.5. Mozilla has announced Firefox2.0.0.20 would be the last version and <a href="http://www.mozilla.com/en-US/firefox/all-older.html">stopped Firefox2 maintenance & supports</a>. The <a href="http://marketshare.hitslink.com/report.aspx?qprid=2&qptimeframe=M&qpsp=119">Firefox3 market share</a> is increasing to 17% at the end of 2008.<br>
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_2XGzavgWfJk/SWBnldqhjhI/AAAAAAAAABo/JVd7-hNjmD4/s1600-h/FF3mshare.png"><img style="cursor:pointer; cursor:hand;width: 400px; height: 154px;" src="http://1.bp.blogspot.com/_2XGzavgWfJk/SWBnldqhjhI/AAAAAAAAABo/JVd7-hNjmD4/s400/FF3mshare.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5287339855848771090" /></a>
<br><br>
The interesting new issue on Firefox3 is SSL cert exception page blocking Selenium automation. On Firefox2, we invoke <a href="https://addons.mozilla.org/en-US/firefox/addon/2131">RMD.xpi</a> XPCOM in <a href="http://sejq.blogspot.com/2008/12/security-alerts-interceptor-for.html">Selenium to intercept all bad cert exception</a> for our self-signed certificates. However, it doesn't work on Firefox3 now that RMD.xpi's author said it <a href="http://www.andrewlucking.com/archives/2008/01/rmd-146-no-firefox3/">only supported Firefox2</a>. Firefox3 introduced a new SSL certificate exception rule. We must find a new workaround.<br><br>
Block step:<br>
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_2XGzavgWfJk/SWBggcETc3I/AAAAAAAAABg/PeY2K74aHZw/s1600-h/sslwarning.png"><img style="cursor:pointer; cursor:hand;width: 320px; height: 181px;" src="http://3.bp.blogspot.com/_2XGzavgWfJk/SWBggcETc3I/AAAAAAAAABg/PeY2K74aHZw/s320/sslwarning.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5287332072939287410" /></a>
<br><br>
Try below selenium ssl test case:
<pre class="html:nogutter:nocontrols" name="code">
<tr>
<td>open</td>
<td>http://kuix.de/mozilla/certwarndiscussion/proposal20061016/</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>https://www.cacert.org</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>https://www.kuix.de</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>https://mur.at</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>https://kuix.de:9443</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>https://www.kuix.de:9443</td>
<td></td>
</tr>
</pre>
I plan to create a new project 'Remember Certificate Exception'(RCE) on <a href="https://addons.mozilla.org/en-US/firefox/">AMO</a> today. The RCE.xpi's purpose is auto-complete Firefox3 certificate exception override.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com1tag:blogger.com,1999:blog-7585488802877910657.post-20288259492816321342008-12-28T06:21:00.000-08:002008-12-28T06:32:27.056-08:00Can Selenium detect if the page has JavaScript errors?We usually have common requirement for Selenium: Check JS error in step.<br><br>
Use case like:<br>
1. beginJsErrorChecker<br>
2. open | http://containJSError.jsp<br>
3. open | http://noissueJS.jsp<br>
4. endJsErrorChecker<br>
It can report url2 has jserror in Selenium:<br>
<pre class="javascript:nogutter:nocontrols" name="code">
[error] JsErrorChecker:[JavaScript Error: "foo is not defined" {file: "http://containJSError.jsp" line: 9}]
</pre>
It's hard to provide a generic solution for all browsers but my team implements above scenario for Selenium IDE only by Firefox chrome Error Console XPCOM APIs.<br><br>
user-extensions.js like:
<pre class="javascript:nogutter:nocontrols" name="code">
if (browserVersion.isChrome) {
var theConsoleListener = {
stepIdx:0, //beginJsErrorChecker command index
observe:function( aMessage ){//async!
dump("Log : " + aMessage.message);
//Error, Warning, Message too noise. We only report "[JavaScript Error:..."
if(aMessage.message != null && aMessage.message.indexOf("[JavaScript Error:") == 0){
LOG.error("JsErrorChecker:" + aMessage.message);
//throw new SeleniumError("Catch JS Error: " + aMessage.message);
//can't throw exception here: pollution to target JSError
//so we manually markFailed
//IDE only
var olddebugIndex = testCase.debugContext.debugIndex;
testCase.debugContext.debugIndex = this.stepIdx;//set actual index
testCase.debugContext.failed = true;
testCase.debugContext.currentCommand().result = 'failed';
editor.view.rowUpdated(testCase.debugContext.debugIndex);
testCase.debugContext.debugIndex = olddebugIndex;//recover
}
},
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
!iid.equals(Components.interfaces.nsISupports)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
}
};
}
Selenium.prototype.doBeginJsErrorChecker = function(){
try {
if (browserVersion.isChrome) {// firefox
theConsoleListener.stepIdx=testCase.debugContext.debugIndex;//set current step idx for async call
var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
aConsoleService.registerListener(theConsoleListener);
aConsoleService.reset();
}else{
throw new SeleniumError("TODO: Non-FF browser...");
}
} catch (e) {
throw new SeleniumError("Threw an exception: " + e.message);
}
};
Selenium.prototype.doEndJsErrorChecker = function(){
try {
if (browserVersion.isChrome) {// firefox
var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
aConsoleService.unregisterListener(theConsoleListener);
aConsoleService.reset();
}else{
throw new SeleniumError("TODO: Non-FF browser...");
}
} catch (e) {
throw new SeleniumError("Threw an exception: " + e.message);
}
};
</pre>
I just add a Selenim listener to Firefox Error Console to make jserror checker work for Selenium-IDE.<br>
Because it is async mode to check JSError, we treat beginJsErrorChecker failed if any step contains JSError in begin...end block.<br>
We also filter all Warning and Message in Error Console, treat Error only as failed here. <br><br>
I pasted solution on <a href="http://clearspace.openqa.org/message/52135">http://clearspace.openqa.org/message/52135</a><br>
<a href="http://jira.openqa.org/browse/SEL-613">http://jira.openqa.org/browse/SEL-613</a>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com4tag:blogger.com,1999:blog-7585488802877910657.post-68577454863431557782008-12-27T06:38:00.000-08:002008-12-27T23:18:50.294-08:00Selenium1.0b buglist for Firefox 3 Chrome TestRunnerThere are a lot of bugs in Selenium1.0b to run on Firefox 3 with chrome TestRunner.html.<br><br>
I list them here:<br>
1. CSS/Resource issue: <a href="http://jira.openqa.org/browse/SIDE-222">http://jira.openqa.org/browse/SIDE-222</a><br>
2. Permission Denied issue: <a href="http://jira.openqa.org/browse/SEL-612">http://jira.openqa.org/browse/SEL-612</a><br>
3. waitForPopUp issue: <a href="http://jira.openqa.org/browse/SIDE-228">http://jira.openqa.org/browse/SIDE-228</a><br>
4. click link issue: <a href="http://jira.openqa.org/browse/SEL-612">http://jira.openqa.org/browse/SEL-614</a><br>
5. UI-Element not work issue: <a href="http://sejq.blogspot.com/2008/12/fix-ui-element-cant-run-bug-in-chrome.html">http://sejq.blogspot.com/2008/12/fix-ui-element-cant-run-bug-in-chrome.html</a>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-44104526053578739752008-12-21T01:11:00.000-08:002008-12-27T23:19:53.794-08:00Two Javascript synchronous sleep functions which won't freeze browserJavascript didn't provide Thread.sleep(ms) method like Java which is useful for synchronization.<br><br>
Most of time we can solve Javascript synchronization by use setTimeout or setInteval. However, using setTimeout requires you to split your function up into discrete processes, which is hard to do for some Javascript logic. What we really need is a free-standing function that could be added inline to any block of code to share the processor on the fly.<br><br>
I encounter a scenario in Selenium today: I want Javascript to sleep to wait for an async call. It's much harder than I thought to implement it. Think about below code:<br>
<pre class="javascript:nogutter:nocontrols" name="code">
function sleep(delay) {
var startTime = new Date();
var endTime = null;
do {
endTime = new Date();
} while ((endTime - startTime);
}
</pre>
It looks fine but if you try it, you will find CPU is very busy executing the while loop and freeze browser. This is not what we wanted.<br><br>
I got 2 workaround methods. The keypoint is JS NOT freeze CPU/browser during sleep:<br>
1)javascript sleep 1: use XMLHttpRequest to do sync call for sleep.jsp
<pre name="code" class="javascript:nogutter:nocontrols">
function wbsleep(ms) {
var startDate = new Date();
while((new Date()-startDate) < ms){
var xmlHttpReq;
try {
// for IE/ActiveX
if(window.ActiveXObject) {
try {
xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
}
// Native XMLHttp
else if(window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
tempurl = "http://localhost/sleeputil.jsp?sleepms="+ms;
xmlHttpReq.open("GET", tempurl, false); // synchron mode
xmlHttpReq.send(null);
}
catch(e) {
}
}
};</pre>
The sleeputil.jsp is very simple, get request parameter sleepms and then do a Java Thread.sleep(sleepms) in doGet. This method is suitable for all browsers but need you provide a server side sleeputil.jsp.<br><br>
2)javascript sleep 2: XPCOM on Firefox chrome only
<pre name="code" class="javascript:nogutter:nocontrols">
/**
* Netscape compatible WaitForDelay function.
* You can use it as an alternative to Thread.Sleep() in any major programming language
* that support it while <strong class="highlight">JavaScript</strong> it self doesn't have any built-in function to do such a thing.
* parameters:
* (Number) delay in millisecond
*/
function nsWaitForDelay(delay) {
try{
/**
* Just uncomment this code if you're building an extention for Firefox.
* Since FF3, we'll have to ask for user permission to execute XPCOM objects.
*/
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Get the current thread.
var thread = Components.classes["@mozilla.org/thread-manager;1"].getService(Components.interfaces.nsIThreadManager).currentThread;
// Create an inner property to be used later as a notifier.
this.delayed = true;
/* Call <strong class="highlight">JavaScript</strong> setTimeout function
* to execute this.delayed = false
* after it finish.
*/
setTimeout("this.delayed = false;", delay);
/**
* Keep looping until this.delayed = false
*/
while (this.delayed) {
/**
* This code will not freeze your browser as it's documented in here:
* https://developer.mozilla.org/en/Code_snippets/Threads#Waiting_for_a_background_task_to_complete
*/
thread.processNextEvent(true);
}
}catch(e) {
}
}</pre>
This is especially suitable for Selenium CORE*ffchrome.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com1tag:blogger.com,1999:blog-7585488802877910657.post-66005901115106266722008-12-20T21:33:00.000-08:002008-12-27T23:21:33.150-08:00Automate HttpFox(HttpWatch) test case for http traffic manipulation in SeleniumSelenium can verify and store values by DOM on current page easily. However, it's hard for Selenium to do manipulation on http traffic like POST Data, http headers, Query String and Content sniffer.<br><br>
I know many QA did http traffic testing manually by 2 famous software:<br>
1) <a href="http://www.httpwatch.com">HTTPWatch</a>: commercial. support both IE and Foxfox. <br>
2) <a href="https://addons.mozilla.org/en-US/firefox/addon/6647">HTTPFox</a>: free, opensource. a Firefox extension.<br><br>
One day, a guy came to my cube and raised a question: Can I stop my tons of manual functional testing with HttpFox, but use Selenium to automate them? Is it possible that we create a bundle of Selenium APIs to manuplate Http Traffic Sniffer operations?<br><br>
Yes, we should add this important feature to Selenium. I finished a beta version to support HttpFox APIs in Selenium:<br>
1) merge httpfox.xpi into Selenium-IDE.xpi<br>
2) leverage XPCOM in httpfoxservice.js HTTPFox provided<br>
3) create Selenium APIs and print http traffic info to Selenium LOG:<br>
<em>startHttpFox4Sel</em><br>
<em>stopHttpFox4Sel</em><br>
<em>clearHttpFox4Sel</em><br>
<em>verifyTextInHttpFoxURLs(Not)Present</em> | textpattern<br>
<em>verifyTextInHttpFoxContent(Not)Present</em> | urlpattern | textpattern<br>
<em>storeContentInHttpFoxByURL</em> | urlpattern | varname<br>
<em>verifyParamInHttpFoxQueryString(Not)Present</em> | urlpattern | param1=value1,param2=value2 list<br>
<em>storeParamInHttpFoxQueryString</em> | param@urlpattern | varname<br>
<em>verifyParamInHttpFoxPostData(Not)Present</em> | urlpattern | param1=value1,param2=value2 list<br>
<em>storeParamInHttpFoxPostData </em>| param@urlpattern | varname<br>
...
<br><br>
Source draft:
<pre name="code" class="javascript:nogutter:nocontrols">
Selenium.prototype.doStartHttpFox4Sel = function() {
try {
if(browserVersion.isChrome){
HttpFox.cmd_hf_clear();
HttpFox.cmd_hf_startWatching();
}
} catch (e) {
throw new SeleniumError("Threw an exception: " + e.message);
}
};
Selenium.prototype.doStopHttpFox4Sel = function() {
try {
if(browserVersion.isChrome){
HttpFox.cmd_hf_stopWatching();
HttpFox.cmd_hf_clear();
}
} catch (e) {
throw new SeleniumError("Threw an exception: " + e.message);
}
};
Selenium.prototype.doClearHttpFox4Sel = function() {
try {
if(browserVersion.isChrome){
HttpFox.cmd_hf_clear();
}
} catch (e) {
throw new SeleniumError("Threw an exception: " + e.message);
}
};
Selenium.prototype.isTextInHttpFoxURLsPresent = function(pattern) {
try {
if(browserVersion.isChrome){
for (var i = 0; i < HttpFox.HttpFoxService.Requests.length; i++){
var request = HttpFox.HttpFoxService.Requests[i];
//1.Time:
var time = formatTimeDifference(request.StartTimestamp, request.EndTimestamp) ;
//2.Sent:
var sent = "";
if (request.IsSending){
sent = humanizeSize(request.getBytesSent(), 6) + "/" + humanizeSize(request.getBytesSentTotal(), 6);
}
else {
sent = humanizeSize(request.getBytesSentTotal(), 6);
}
//3.Received:
var received = "";
if (request.IsSending){
received = "*";
}
if (!request.IsFinished){
// show loading body progress
received = humanizeSize(request.getBytesLoaded(), 6) + "/" + humanizeSize(request.getBytesLoadedTotal(), 6);
}else{
received = humanizeSize(request.getBytesLoaded(), 6);
}
if (request.IsFromCache || request.ResponseStatus == 304){
received = "(" + received + ")";
}
//4.Method:
var method = request.RequestMethod;
//5.Result:
var result = "";
if (request.IsAborted){
result = "(Aborted)";
}else if (request.isError()){
result = "(Error)";
}else if (request.IsFromCache && (request.ResponseStatus != 304)) {
result = "(Cache)";
}else if (!request.HasReceivedResponseHeaders && !request.IsFinal){
result = "*";
}else{
result = request.ResponseStatus;
}
//6.Type:
var type = "";
if (request.hasErrorCode()){
if (request.ContentType){
type = request.ContentType + " (" + request.Status.toString(16) + ")";//we omit nsResultErrors translate
}else{
type = request.Status.toString(16);
}
}else if (!request.HasReceivedResponseHeaders && !request.IsFromCache && !request.IsFinal){
type = "*";
}else if (request.isRedirect()){
if (request.ResponseHeaders && request.ResponseHeaders["Location"]){
type = "Redirect to: " + request.ResponseHeaders["Location"];
}else{
type = "Redirect (cached)";
}
}else{
type = request.ContentType;
}
//7.URL
var urlstring = request.Url ;
//TODO: LOG.info(http sniffer info);
//TODO: verify as you like by PatternMatcher
} //end for
}//end chrome
} catch (e) {
throw new SeleniumError("Threw an exception: " + e.message);
}
};
</pre>
<br>
Now, QA can automate HttpFox steps in Selenium. They don't need to do http traffic testing manually all days.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com16tag:blogger.com,1999:blog-7585488802877910657.post-54678925428914223112008-12-20T20:52:00.000-08:002008-12-27T23:24:30.339-08:00Dedicated to developing Selenium Core Firefox chrome branchSince my team has chosen Selenium Core-Firefox chrome with Selenese table test case as primary Selenium testing method, my task will focus on Selenium Core Firefox chrome branch development(A brand new Selenium-IDE). I will also contribute a bundle of Java APIs to play Selenium Core*ffchrome. Moreover, I should provide a GRID framework for huge test case number run.<br><br>
"Simply the best". No proxy server, no Remote Control, no IE/HTA, no Java Test Case, no Same Origin Policy, I really found this mode is efficient but powerful as long as we provide an enterprise framework.<br><br>
For QA, they only need learn Selenese table knowledge without Java programming skills. They don't need to install any complex framework but only setup our Selenium-IDE version on their desktop.<br><br>
For framework developer, then needn't build a heavyweight infrastructure like proxy server, client driver. What they need do are only:<br>
1) Let Selenium-Core*ffchrome save detailed enough result capture/snapshot with well formed structure to local file system.<br>
2) Extend chrome URL parameters to meet all configuration requirements. We can benifit a lot from Mozilla APIs and do some fantasitic jobs for Selenium core(That why we choose Firefox as Selenium browser).<br>
3) A bundle of Java APIs to play Selenium-Core*ffchrome under isolated profile and parse run results to Java Objects. We can define an atomic unit(1-3) as one Selenium Agent.<br>
4) A GRID Java framework to distribute huge test case number run on Agents with scalability. DB support is necessary to save both test case info and run result info.<br>
5) Then a GUI web based test case maintenance and execution portal is possible with above back end framework supporting.<br><br>
Comparing to official RC+GRID solution, our solution is more suitable for acceptance test, integrating test & regression test(black box).Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com1tag:blogger.com,1999:blog-7585488802877910657.post-11730824630216904122008-12-15T01:00:00.000-08:002008-12-28T05:28:23.457-08:00Selenese flowControl extensions - advanced support for include templateAs my previous post, Selenese flowControl extensions work well on IDE and Core now.
However, when guys used another powerful extension <a href="http://wiki.openqa.org/display/SEL/include">'include'</a>, they found flowControl not work in include template steps.<br><br>
I provide a quick workaround here. Please revise include extension javascript as below:
<pre class="javascript:nogutter:nocontrols" name="code">
Selenium.prototype.doInclude = function(locator, paramString) {
LOG.debug(IncludeCommand.LOG_PREFIX + " Version " + IncludeCommand.VERSION);
var includeCommand = new IncludeCommand();
includeCommand.doInclude(locator, paramString);
//Jerry Qian: add flowControl support for include template steps
try{
htmlTestRunner.currentTest.gotoLabels = {};
htmlTestRunner.currentTest.whileLabels = { ends: {}, whiles: {} };
htmlTestRunner.currentTest.initialiseLabels();
}catch(e){}
//End flowControl
};</pre>
Include template steps can use flowControl commands now.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-54438229150933808682008-12-13T22:35:00.000-08:002008-12-28T05:29:57.330-08:00Selenese flowControl extensionsUsually, we don't need to do conditional logic in Selenese table. Selenium RC programming language is more suitable for complex logic. But sometimes we still want to add some conditional steps in Selenese, like if...else, while. <br><br>
Fortunately, there are already flow control extensions on openqa's wiki.<br>
<a href="http://wiki.openqa.org/display/SEL/flowControl">http://wiki.openqa.org/display/SEL/flowControl</a><br><br>
It can meet most of flow control requirements for Selenese. We still recommend use RC to implement more complicated logic.<br><br>
Also some people work on both Core and IDE. They found this extensions not work on IDE. It's a CORE version.<br><br>
One guy contributed an IDE version: <a href="http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html">http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html</a>. IDE user can also use it.<br><br>
So I combined them to a unified flowControl extensions: support both IDE and CORE.<br><br>
The simplest code:
<pre class="javascript:nogutter:nocontrols" name="code">var sel_locstr = window.location.href;
if(sel_locstr.indexOf("selenium-ide.xul") != -1){ //IDE mode
// paste IDE extension here
}else{//Core mode
// paste Core extension here
} </pre>
Enjoy!Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-91025318225223098422008-12-12T06:10:00.000-08:002008-12-28T05:31:23.954-08:00Firefox3 new security rule: Selenium no CSS on Chrome TestRunnerFirefox 3 introduced more strict security rules than older version. Many Selenium weird issues on FF3 are related to it, while most of these issues didn't happen on FF2.<br><br>
Today I encountered one SeleniumIDE1.0b2 bug: [<a href="http://jira.openqa.org/browse/SIDE-222">SIDE-222</a>]Test execution is not possible in chrome mode in Firefox 3.<br><br>
FF3 Error Console reported: <pre class="javascript:nogutter:nocontrols" name="code">Security Error: Content at (local test suite html address like file:///c:/seltest/testsuite1.html) may not load or link to "chrome://selenium-ide-testrunner/content/selenium/selenium-test.css" </pre>
It seems FF3's default security settings not allow external file access chrome:// resource. <br>
I read Mozilla docs: <a href="https://developer.mozilla.org/en/Chrome_Registration#contentaccessible">https://developer.mozilla.org/en/Chrome_Registration#contentaccessible</a><br><br>
It said: (New in FF3) Chrome resources can no longer be referenced from within <img>, <script>, or other elements contained in, or added to, content that was loaded from an untrusted source. This restriction applies to both elements defined by the untrusted source and to elements added by trusted extensions. If such references need to be explicitly allowed, set the contentaccessible flag to yes to obtain the behavior found in older versions of Firefox. <br><br>
So, I try to modify Selenium-IDE1.0b2's chrome.manifest file.
<pre class="javascript:nogutter:nocontrols" name="code">
content selenium-ide-testrunner jar:chrome/selenium-ide.jar!/content/ xpcnativewrappers=no
content selenium-ide-testrunner jar:chrome/selenium-ide.jar!/content/ xpcnativewrappers=no contentaccessible=yes</pre>
SeleniumIDE1.0b2 displayed CSS correctly this time on FF3 Chrome TestRunner.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com1tag:blogger.com,1999:blog-7585488802877910657.post-86625797314950627732008-12-03T21:43:00.000-08:002008-12-28T05:32:39.542-08:00Test Flex/Flash in SeleniumThere are many automation tools for testing Flex & Flash RIA web page, like <a href="http://automatedqa.com/products/testcomplete">TestComplete</a>, QTP. However, they are all not free. It's good news if Selenium supports such kind of RIA testing.<br><br>
We found there are some interesting projects on Selenium for Flex/Flash testing.<br><br>
Here is a topic: <a href="http://www.agimatec.de/blog/2008/11/selenium-flex-tests-with-maven/">http://www.agimatec.de/blog/2008/11/selenium-flex-tests-with-maven/</a><br><br>
Introduction:<br>
<a href="http://sourceforge.net/projects/seleniumflexapi/">SeleniumFlexApi</a> is in one part a Flex library which needs to be included in your app and on the other part an extension to the Selenium IDE. I like the Flex part, because it makes it easy to dive over Javascript into the details of your Flex app. What I don’t really like is the Javascript extension. Yes, it is not only a Selenium IDE part and you can include it into the start of the Selenium Server, but it is far away from Java and Maven.<br><br>
<a href="http://code.google.com/p/flash-selenium/">FlashSelenium</a> is a piece of code which let’s you talk from Java over Selenium with your Flex app. The Java part is very handy, but you need to code into Flex, which methods you could call over your bridge. So I need to write special code, which opens the bridge. The SeleniumFlexAPI is much better in this part.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com3tag:blogger.com,1999:blog-7585488802877910657.post-71522779772924586582008-12-01T07:47:00.000-08:002008-12-28T05:33:50.382-08:00Fix ui-element can't run bug in Chrome TestRunner modeSelenium-IDE1.0b2 introduced a new feature: UI-Element.
It is very useful feature for annoyed XPATH EL.<br><br>
We try demo in Selenium IDE panel successfully. However, when we try UI-Element test case in Chrome TestRunner, even if we set &userExtensionsURL=chrome://selenium-ide/content/ui-element.js,file:///c:/ui/my-ui-map.js correctly in chrome URL, it failed to load any UI-Element feature.<br><br>
Weird, we have discussed it on openqa forum.
Finally, I fix this bug in chrome://selenium-ide/content/ui-element.js
<pre class="javascript:nogutter:nocontrols" name="code">
function is_IDE()
{
//[Begin Fix]
var locstr = window.location.href;
if(locstr.indexOf("selenium-ide.xul") != -1){
//IDE mode
return true;
}else{
return false;
}
//[End]
return (typeof(SeleniumIDE) != 'undefined');
}</pre>
It seems <pre class="javascript:nogutter:nocontrols" name="code">typeof(SeleniumIDE) != 'undefined'</pre> not work in Chrome TestRunner mode.<br><br>
Finally, with above fix, UI-Element works in both IDE and Chrome TestRunner.<br><br>
More discussion: <a href="http://clearspace.openqa.org/message/53306">http://clearspace.openqa.org/message/53306</a>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-54877588621459445562008-11-18T07:19:00.000-08:002008-12-28T05:35:40.524-08:00Write user-extensions.js working for both Selenium-IDE and Selenium-CoreSometimes we found our user-extensions.js(like include cmd)work on Selenium-Core but error on Selenium-IDE, or vise versa.<br><br>
The reason is IDE and Core used 30% different js objects.<br><br>
We can write below style user-extension to support both IDE and Core.<br>
Sample:
<pre class="javascript:nogutter:nocontrols" name="code">
if(IDE_MODE){
//IDE manner
}else{//CORE_MODE
//Core manner
}</pre>
The key function here is how to determine current mode type by javascript?<br>
Simple workaround code:
<pre class="javascript:nogutter:nocontrols" name="code">
function isIDE(){
var locstr = window.location.href;
if(locstr.indexOf("selenium-ide.xul") != -1){
//IDE mode
return true;
}else{
return false; //Core mode
}
}</pre>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-3228940046303754272008-11-17T06:38:00.000-08:002008-12-28T05:39:51.284-08:00Multiple Profiles running simultaneously synchronization in SeleniumJRunnerWe must assign each SeleniumJRunner a unique profile name at one time.<br>
Otherwise, if 2 instances use the same profile name at one time, Firefox will report <a href="http://support.mozilla.com/zh-CN/kb/Firefox+is+already+running+but+is+not+responding">"Firefox is already running..."</a> error.<br><br>
Assume we have pre-created Firefox profiles on one machine with name:<br>
testprofile1<br>
testprofile2<br>
testprofile3<br>
...<br>
testprofile9<br><br>
We can lock profile name when one SeleniumJRunner is using it and unlock it when SeleniumJRunner quit. If there is no free profile name, let new SeleniumJRunner wait.<br><br>
Sample code:<br>
<pre class="java:nogutter:nocontrols" name="code">
public static String lockAndGetAvailableProfile(String[] allProfiles) {
FileLock lock = null;
for (int i = 0; i < allProfiles.length; i++) {
try {
RandomAccessFile raf = new RandomAccessFile(PROFILE_LOCK_FOLDER
+ "/" +i+".lck" , "rw");
FileChannel fileChannel = raf.getChannel();
lock = fileChannel.tryLock();
if(lock != null && lock.isValid()
&& !lock.isShared()){
return allProfiles[i];
}else{
lock = null;
fileChannel.close();
raf.close();
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
return "No available profile";
}
</pre>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-31532447750558889792008-11-16T05:59:00.000-08:002008-12-28T05:42:15.973-08:00Daemon AutoIt3 process to click popup and alerts for SeleniumThere are always all kinds of popup and alerts during selenium running. If they are not clicked out, Selenium may be blocked and timed out.<br><br>
We recommend to use a free tool <a href="http://www.autoitscript.com/AutoIt/">AutoIt3 </a> to write daemon scripts to click out any popup. Make sure selenium run smoothly. <br><br>
Sample Autoit3 scripts:
<pre class="vb:nogutter:nocontrols" name="code">
If WinExists("Alert") Then
WinActivate("Alert")
ControlSend ("Alert", "", "", "{SPACE}")
ContinueLoop
EndIf
</pre>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-89230293235685908862008-11-15T05:47:00.000-08:002008-12-28T05:43:41.328-08:00Customize Selenium Chrome TestRunner profile in JRunnerThere is a prefs.js configuration file for each Firefox profile.<br>
Selenium Java Runner can do some necessary customization before launch Firefox TestRunner instance.<br>
Read prefs.js docs: <a href="http://kb.mozillazine.org/Prefs.js_file">http://kb.mozillazine.org/Prefs.js_file</a><br><br>
Sample prefs.js customize code:
<pre class="java:nogutter:nocontrols" name="code">
PrintStream out = new PrintStream(new FileOutputStream(prefsJS, true));
// Don't ask if we want to switch default browsers
out.println("user_pref('browser.shell.checkDefaultBrowser', false);");
// suppress authentication confirmations
out.println("user_pref('network.http.phishy-userpass-length', 255);");
// Disable pop-up blocking
out.println("user_pref('browser.allowpopups', true);");
out.println("user_pref('dom.disable_open_during_load', false);");
out.println("user_pref('startup.homepage_welcome_url', '');");
// Disable Restore your session dialog. Always start a new session
out.println("user_pref('browser.sessionstore.enabled', false);");
// Disable security warnings
out.println("user_pref('security.warn_submit_insecure', false);");
out.println("user_pref('security.warn_submit_insecure.show_once', false);");
out.println("user_pref('security.warn_entering_secure', false);");
out.println("user_pref('security.warn_entering_secure.show_once', false);");
out.println("user_pref('security.warn_entering_weak', false);");
out.println("user_pref('security.warn_entering_weak.show_once', false);");
out.println("user_pref('security.warn_leaving_secure', false);");
out.println("user_pref('security.warn_leaving_secure.show_once', false);");
out.println("user_pref('security.warn_viewing_mixed', false);");
out.println("user_pref('security.warn_viewing_mixed.show_once', false);");
// Disable cache
out.println("user_pref('browser.cache.disk.enable', false);");
out.println("user_pref('browser.cache.memory.enable', true);");
// Disable "do you want to remember this password?"
out.println("user_pref('signon.rememberSignons', false);");
// Disable any of the random self-updating crap
out.println("user_pref('app.update.auto', false);");
out.println("user_pref('app.update.enabled', false);");
out.println("user_pref('extensions.update.enabled', false);");
out.println("user_pref('browser.search.update', false);");
out.println("user_pref('browser.safebrowsing.enabled', false);");
//enable javascript
out.println("user_pref('javascript.enabled', true);");
//Optional Tips: User-Agent hijack for http traffic debug
//out.println("user_pref('general.useragent.override', 'Here crack user-agent');"); out.close();</pre>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-86540767861018419322008-11-14T05:17:00.000-08:002008-12-28T05:45:54.177-08:00Include JS src file in Firefox Chrome Javascript fileTo include a Javascript src file in HTML, it's very simple:
<pre class="html:nogutter:nocontrols" name="code"><script src="scripts/b.js" type="text/javascript"></script></pre>
However, how to implement above logic in a Chrome js file(XUL missed including b.js).<br>
There is a XPCOM API @mozilla.org/moz/jssubscript-loader;1<br>
Sample:
<pre class="javascript:nogutter:nocontrols" name="code">
const subScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
//file:/// path for XPCOM. http:// not support
subScriptLoader.loadSubScript('file:///c:/scripts/b.js', this);</pre>
In normal js file(non-chrome), it's also simple.<br>
Sample:
<pre class="javascript:nogutter:nocontrols" name="code">
document.write('<script src="scripts/b.js" type="text/javascript"></script>');</pre>
This tip is useful for Selenium-IDE enhancement.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-90204233147156929432008-11-13T04:51:00.000-08:002008-12-28T05:48:03.144-08:00Security Alerts Interceptor for Selenium-IDEThere are 2 kinds of HTTPs Certification Security Alerts in Firefox. <br>
1) Domain name mismatch<br>
2) Certificate expired<br>
Read <a href="http://kb.mozillazine.org/Security_Error:_Domain_Name_Mismatch_or_Server_Certificate_Expired">http://kb.mozillazine.org/Security_Error:_Domain_Name_Mismatch_or_Server_Certificate_Expired</a><br>
Unfortunately, Firefox 2 didn't provide a preferences entry to disable or hidden alerts.<br>
These annoyed alerts slow down selenium speed and block selenium automation if we don't click out alerts.<br><br>
There is a Firefox extension <a href="https://addons.mozilla.org/en-US/firefox/addon/2131">Remember Mismatch Domains(RMD.xpi)</a> to add a "Don't warn me again about this certificate for this domain" checkbox to the Domain Mismatch and Expired Certificate warning windows. When selected the domain name and security certificate domain pair (or certificate and expiration date pair) is stored in a Firefox preference and the security error dialogue will be bypassed on subsequent visits.<br><br>
The author provided a XPCOM to destroy Security Alerts Window before it displays in Firefox. We can integrate this XPCOM with Selenium-IDE and provide Security Alerts Interceptor feature.<br><br>
Here are steps and code:<br>
1) copy /platform folder from RMD.xpi to selenium-ide.xpi<br>
2) copy rmdBadCertHandler.js and rmdIBadCertHandler.xpt to /components folder<br>
3) edit rmdBadCertHandler.js<br>
<pre class="javascript:nogutter:nocontrols" name="code">
_isRemembered: function (handler_type, target_url, cert) {
return true;
//intercept and kill all security alerts
//or add a preference entry here and return true or false
...
}</pre>
NOTE: it is used for Firefox 2 only. Firefox 3 has a new security exception handler.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com1tag:blogger.com,1999:blog-7585488802877910657.post-27743887782614954282008-11-11T04:28:00.000-08:002008-12-28T05:48:56.964-08:00Selenium close all Firefox windows in profile when finish runThere is a Chrome URL parameter &close=true in Selenium-IDE. When set to true, it will automatically close Selenium Firefox windows when finish run. However, if application window has popuped child windows like ads, selenium can't close these popup windows when quit.<br><br>
This has risk to lock Firefox profile when multiple Firefox profiles running simuteniously. Please refer to <a href="http://support.mozilla.com/en-US/kb/Firefox+is+already+running+but+is+not+responding">"Firefox is aleady running issue"</a><br>
Enhance Selenium-IDE by XPCOM API: close all Firefox windows under current profile.
Add logic when Selenium quit(close=true).<br>
Sample code:
<pre class="javascript:nogutter:nocontrols" name="code">
var windowManager = Components
.classes['@mozilla.org/appshell/window-mediator;1'].getService();
var windowManagerInterface = windowManager
.QueryInterface( Components.interfaces.nsIWindowMediator);
var enumerator = windowManagerInterface.getEnumerator( null );
var appStartup = Components
.classes['@mozilla.org/toolkit/app-startup;1'].
getService(Components.interfaces.nsIAppStartup);
while ( enumerator.hasMoreElements() )
{
var domWindow = enumerator.getNext();
if (("tryToClose" in domWindow)
&& !domWindow.tryToClose())
return false;
domWindow.close();
};
appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit);
</pre>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-44677969242098278982008-11-10T04:08:00.000-08:002008-12-28T05:50:09.756-08:00Save to local files with XPCOM for Selenium Firefox ChromeWe save selenium run snapshot/result/log to local files instead of complex POST to server solution. We require APIs in browser(out of Security Sandbox) for local files accessing. <br><br>
In IEHTA, there is ActiveX object FSO to access local files.<br>
<pre class="javascript:nogutter:nocontrols" name="code">
var objFSO = new ActiveXObject("Scripting.FileSystemObject");</pre>
Is there a similar object in Mozilla Firefox Chrome?<br>
The answer is XPCOM object @mozilla.org/file/local;1<br><br>
Save to file Sample:
<pre class="javascript:nogutter:nocontrols" name="code">
function saveFile(fileName, val){
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
//alert("Permission to save file was denied.");
}
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(fileName);
if (file.exists() == false) {
//alert("Creating file... " );
file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
}
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
outputStream.init( file, 0x04 | 0x08 | 0x20, 420, 0 );
//UTF-8 convert
var uc = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
uc.charset = "UTF-8";
var data_stream = uc.ConvertFromUnicode(val);
var result = outputStream.write(data_stream, data_stream.length );
outputStream.close();
}</pre>
We use UTF-8 encode here.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-26560593907191053182008-11-09T03:55:00.000-08:002008-12-28T05:51:12.266-08:00PseudoTestRunner.html to run Selenium Chrome by cmdlineLaunch Selenium Chrome TestRunner by cmdline: <em>firefox.exe -chrome "chrome://selenium-ide-testrunner/content/selenium/TestRunner.html..." </em>will cause many weird issues on Firefox.<br>
I'm not sure the root cause which maybe related to Firefox Chrome Security Strategy for -chrome parameter.<br><br>
Here is a workaround:<br>
Hijack selenium-ide.xpi. Under selenium-ide\content\selenium\ add a file PseudoTestRunner.html<br>
Source:
<pre class="html:nogutter:nocontrols" name="code">
<html>
<head><title>Pseudo Test Runner - Used for launch Chrome by Cmdline</title></head>
<body>
<script language="javascript">
var strHref;
var intParamsStartIndex;
var strParams;
strHref = window.location.href;
intParamsStartIndex = strHref.indexOf("?");
strParams = strHref.substring(intParamsStartIndex);
window.open("chrome://selenium-ide-testrunner/content/selenium/TestRunner.html" + strParams);
window.close();
</script>
</body>
</html>
</pre>
Then please always use PseudoTestRunner.html instead of TestRunner.html in cmdline, keep the same parameter list in URL.<br><br>
Refer to topic: <a href="http://clearspace.openqa.org/message/51801#51801">http://clearspace.openqa.org/message/51801#51801</a>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-60199088160787238142008-11-08T02:13:00.000-08:002008-12-28T05:54:51.393-08:00How to let JAVA play with Selenium Firefox Chrome TestRunnerSelenium Firefox Chrome TestRunner is written by JS/DHTML. When we want to embed Firefox Chrome TestRunner engine into our testing framework. We are asking for a way to let JAVA play with Firefox Chrome TestRunner. You can also refer to Selenium-RC source code to launch a browser. Here is a workaround solution with pseudo code.<br><br>
1. In & Output of 'Selenium Firefox Chrome TestRunner' component for JAVA
IN: it is usually URL trigger for running. Chrome URL with parameters looks like: <br>
<em>chrome://selenium-ide-testrunner/content/selenium/TestRunner.html?test=file:///c:/testing/MyTestSuite.html&auto=true&multiWindow=true&userExtensionsURL=http://localhost/user-extensions.js,http://localhost/ui/my-ui-map.js&close=true&[other self defined parms]</em><br>
We can see Selenium passed parameters by chrome URL for input. We can add more self defined params by modify Selenium-IDE code.<br>
If we can convert all parameters in JAVA to chrome URL parameters, it's possible to let JAVA invoke Selenium-IDE.<br><br>
OUTPUT: one output choice provided by S-CORE is using POST data when Selenium closed. It required you create a server side receiver.<br>
One better solution is S-IDE save run snapshot/result/log runtimely to file system directly. We treat these important data as output.<br><br>
For offical docs about IN&OUTPUT, refer to <a href="http://seleniumhq.org/projects/core/usage.html">http://seleniumhq.org/projects/core/usage.html</a><br><br>
2. 'IN' Wrapper in JAVA<br>
We create a Java Object as a chrome URL paramters wrapper, simple like:<br>
<pre class="java:nogutter:nocontrols" name="code">public class SeleniumRequest implements Serializable {
private String test;
private String auto;
private String multiWindow;
...
public String getAuto() {
return auto;
}
public void setAuto(String auto) {
this.auto = auto;
}
...
}</pre>
3. 'OUTPUT' Wrapper in JAVA<br>
We also create a Java Object as atomic run result wrapper, simple like:
<pre class="java:nogutter:nocontrols" name="code">
public class SeleniumResult implements Serializable {
private int testRuns;
private int testFailures;
private String resultSummary;
private String logFilePath;
...
public String getResultSummary() {
return resultSummary;
}
public void setResultSummary(String resultSummary) {
this.resultSummary= resultSummary;
}
...
}</pre>
Detailed run results are saved on file system by S-IDE. logFilePath is the path for their index file.<br><br>
4. SeleniumJRunner in Java<br>
Now, we can define a very simple & generic interface for run S-IDE in Java.
<pre class="java:nogutter:nocontrols" name="code">
public interface SeleniumJRunner {
public SeleniumResult run(SeleniumRequest request);
}</pre>
We assume this run API is sync mode, which means run() will be blocked in Java thread until S-IDE finished run and generate OUTPUT.<br><br>
5. SeleniumResultParser.java<br>
S-IDE saved all results in file system, we need a Java class to parse file content and set to SeleniumResult object. This is part of SeleniumJRunner implementation logic. To do html file parser in Java, there are many opensource lib. You can use <a href="http://sourceforge.net/projects/nekohtml">Nekohtml</a>.<br><br>
6. SyncExecutor.java<br>
Since S-IDE is an external process for Java. We need launch it with parameters from Java in sync mode. Usually, JAVA API Runtime.getRuntime().exec() meets basic requirement. However, we need a timedout mechanism and safely execution which Runtime.getRuntime() doesn't provide. We create a powerful but simple SyncExecutor util. For related topic, refer to <a href="http://www.aviransplace.com/2008/04/17/how-to-safely-execute-process-from-java">how to safely execute process from java</a>
<br><br>
7. Launch Selenium with profile isolation on the same machine<br>
It is super Firefox can run multiple instances with session/cache isolation concurrently on the same machine by Firefox Profiles mechanism.<br>
We need to add -p ProfileName -no-remote parameters to Firefox cmdline.<br>
For multiple Firefox profiles run together, refer to <a href="http://clan.yo2.cn/run-multiple-firefox-profiles-simultaneously.html">http://clan.yo2.cn/run-multiple-firefox-profiles-simultaneously.html</a><br><br>
8. There is critical issue for launch Chrome TestRunner in cmdline mode<br>
User may encounter weird issue if launch Chrome TestRunner in cmdline like <em>firefox.exe -chrome "chrome://selenium-ide-testrunner/content/selenium/TestRunner.html..." </em>. It's hard to resolve.
In JRunner, we must choose a workaround substitution.<br>
For solution, read topic: <a href="http://clearspace.openqa.org/message/51801#51801">http://clearspace.openqa.org/message/51801#51801</a>Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com1tag:blogger.com,1999:blog-7585488802877910657.post-3467828710892350942008-11-07T01:20:00.000-08:002008-12-28T05:56:55.316-08:00Build a regression automation testing framework based on Selenium FIT modeWhen company only has 100 regression test cases written by Selenese, QA steps to do regression tasks by Selenium FIT mode:<br>
1) Organize test cases files with suites files on local driver or shared driver<br>
2) Open Chrome TestRunner in Firefox<br>
3) Import test suites address in file sytem, click run<br>
4) Monitor and wait for run finished, manually collect run result and write a run report with generic result info. <br><br>
Assume your company business's growth and you have 1000+ regression test cases.<br>
How to execute these cases in a short time and generate report with detailed enough info automatically?<br>
0) All QA upload and maintain test cases on a central portal.<br>
1) Choose test cases you want to kick off regression from case repository<br>
2) Specify necessary parameter for regression and kick off<br>
3) A scalable machine matrix in backend begin to do automation run parallelly. There are also multiple instances running simuteniously on same machine. Each instance used Selenium FIT engine. The run snapshot/result/log are stored into filesytem/DB runtimely by above instances called Agent.<br>
4) When all run finished, a report can be generated from file sytem/DB.<br><br>
It's feasible to implement such a system with Selenium FIT mode.<br><br>
Comparing to similar system based on S-RC+S-GRID:<br>
1) No need proxy server, more lightweight framework. No need precompile like .java test case source.<br>
2) Firefox Chrome TestRunner is more stable and faster than RC Runner. It can bypass many issues which RC can't resolve. Chrome XPCOM APIs is very powerful for develop Selenium new features.<br>
3) User only need to know how to create a Selenese test case, no other skill requirement.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0tag:blogger.com,1999:blog-7585488802877910657.post-30215080442961088992008-11-06T00:04:00.000-08:002008-12-28T06:00:07.504-08:00FIT mode best choice: running Selenium with Firefox Chrome TestRunnerI don't think Selenium-RC is the best choice for QA who does feature testing & regression testing with blackbox style, esp. those who doesn't have programming background.<br><br>
S-RC(JAVA) disadvantages for blackbox QA/regression testing:<br>
1) programming skills trainning cost for QA<br>
2) test code complexity for maintenance <br>
3) bad HTTPS/SSL page support<br>
4) popup/alerts make automation stuck, require an autoclick alerts mechanism<br>
5) not stable and with weird issues caused by Proxy Server<br>
6) not lightweight tools, need setup environment<br>
7) still need do 2nd around development to integrate with regression distributed system(even if S-GRID).<br><br>
FIT mode is familiared by QA. There has 3 ways:<br>
1) deploy Selenium CORE/TEST on testing server<br>
2) MS IEHTA with test case repository anywhere<br>
3) Firefox Chrome by Selenium-IDE with test case repository anywhere<br><br>
For 1), some company has restriction to deny to do deployment<br>
For 2), IEHTA is unstable and has critial issues such as multiwindow popup,xpath slowness etc. It's also hard to provide a session/cache isolation solution for multiple instances running simultaniously on one machine. It's also hard to create a recorder for IE.<br><br>
I think running Selenium with Firefox Chrome TestRunner is the best choice for FIT mode.<br>
1) Selenium-IDE is a good tool with recorder and still can do huge improvements.<br>
2) Stable and well support HTTPS. Well support multiwindow.<br>
3) multiple selenium running simultaniously on same machine with session/cache isolation by Firefox profiles mechanism<br>
4) set FF preferences to let Selenium not stuck(click out popup/alerts)<br>
5) save run snapshot/results/log to local file system other than postUrl solution<br>
6) No need any proxy server. No need any additional installation and configuration.<br>
7) Opensource Firefox platform is developer friendly. Firefox Chrome's XPCOM APIs can support us to implement all kinds of selenium features.<br><br>
However, the bottleneck for openqa's FIT mode(Esp. Selenium-IDE) not become enterprise usage:<br>
1) Selenium-IDE doesn't save down detailed enough snapshot/results/log to local file system which is the significant requirement for enterprise tools. Many other significant requirements also haven't been implemented.<br>
2) FIT mode doesn't provide neccessary development SDK. We can build our enterprise test case maintenance system with GUI/webflow, parallel execution system with distributed infrastructure, result reporting system with DB/file system. However, we need SDK APIs to integrate Selenium FIT engine into these systems.<br><br>
Most of developers are contributing for S-RC product on community. I hope openqa can also push Selenium-IDE FIT product line for enterprise usage.Jerry Qianhttp://www.blogger.com/profile/15180821609649895287noreply@blogger.com0