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
  }
}

No comments:

Post a Comment