Saturday, December 20, 2008

Dedicated to developing Selenium Core Firefox chrome branch

Since 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.

"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.

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.

For framework developer, then needn't build a heavyweight infrastructure like proxy server, client driver. What they need do are only:
1) Let Selenium-Core*ffchrome save detailed enough result capture/snapshot with well formed structure to local file system.
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).
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.
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.
5) Then a GUI web based test case maintenance and execution portal is possible with above back end framework supporting.

Comparing to official RC+GRID solution, our solution is more suitable for acceptance test, integrating test & regression test(black box).

Monday, December 15, 2008

Selenese flowControl extensions - advanced support for include template

As my previous post, Selenese flowControl extensions work well on IDE and Core now. However, when guys used another powerful extension 'include', they found flowControl not work in include template steps.

I provide a quick workaround here. Please revise include extension javascript as below:
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
};
Include template steps can use flowControl commands now.

Saturday, December 13, 2008

Selenese flowControl extensions

Usually, 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.

Fortunately, there are already flow control extensions on openqa's wiki.
http://wiki.openqa.org/display/SEL/flowControl

It can meet most of flow control requirements for Selenese. We still recommend use RC to implement more complicated logic.

Also some people work on both Core and IDE. They found this extensions not work on IDE. It's a CORE version.

One guy contributed an IDE version: http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html. IDE user can also use it.

So I combined them to a unified flowControl extensions: support both IDE and CORE.

The simplest 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
} 
Enjoy!

Friday, December 12, 2008

Firefox3 new security rule: Selenium no CSS on Chrome TestRunner

Firefox 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.

Today I encountered one SeleniumIDE1.0b2 bug: [SIDE-222]Test execution is not possible in chrome mode in Firefox 3.

FF3 Error Console reported:
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" 
It seems FF3's default security settings not allow external file access chrome:// resource.
I read Mozilla docs: https://developer.mozilla.org/en/Chrome_Registration#contentaccessible

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.

So, I try to modify Selenium-IDE1.0b2's chrome.manifest file.
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
SeleniumIDE1.0b2 displayed CSS correctly this time on FF3 Chrome TestRunner.

Wednesday, December 3, 2008

Test Flex/Flash in Selenium

There are many automation tools for testing Flex & Flash RIA web page, like TestComplete, QTP. However, they are all not free. It's good news if Selenium supports such kind of RIA testing.

We found there are some interesting projects on Selenium for Flex/Flash testing.

Here is a topic: http://www.agimatec.de/blog/2008/11/selenium-flex-tests-with-maven/

Introduction:
SeleniumFlexApi 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.

FlashSelenium 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.

Monday, December 1, 2008

Fix ui-element can't run bug in Chrome TestRunner mode

Selenium-IDE1.0b2 introduced a new feature: UI-Element. It is very useful feature for annoyed XPATH EL.

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.

Weird, we have discussed it on openqa forum. Finally, I fix this bug in chrome://selenium-ide/content/ui-element.js
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');
}
It seems
typeof(SeleniumIDE) != 'undefined'
not work in Chrome TestRunner mode.

Finally, with above fix, UI-Element works in both IDE and Chrome TestRunner.

More discussion: http://clearspace.openqa.org/message/53306

Tuesday, November 18, 2008

Write user-extensions.js working for both Selenium-IDE and Selenium-Core

Sometimes we found our user-extensions.js(like include cmd)work on Selenium-Core but error on Selenium-IDE, or vise versa.

The reason is IDE and Core used 30% different js objects.

We can write below style user-extension to support both IDE and Core.
Sample:
if(IDE_MODE){
   //IDE manner
}else{//CORE_MODE
   //Core manner
}
The key function here is how to determine current mode type by javascript?
Simple workaround code:
function isIDE(){
  var locstr = window.location.href;  
  if(locstr.indexOf("selenium-ide.xul") != -1){
      //IDE mode   
      return true;
  }else{
      return false; //Core mode
  }
}