Javascript jQuery与prototype Selenium没有冲突

Javascript jQuery与prototype Selenium没有冲突,javascript,jquery,selenium,prototype,Javascript,Jquery,Selenium,Prototype,我正在使用Selenium IDE调用自定义函数文件中的jQuery库Selenium uses prototype我相信以前没有遇到过问题,但最近对Firefox的更新似乎导致了一个问题。我发现了这个问题,它源于这个函数 /* allow use of jQuerys global variable $ */ function _getGlobalVar(varName) { var win = selenium.browserbot.getUserWindow(); if (wi

我正在使用Selenium IDE调用自定义函数文件中的jQuery库Selenium uses prototype我相信以前没有遇到过问题,但最近对Firefox的更新似乎导致了一个问题。我发现了这个问题,它源于这个函数

/* allow use of jQuerys global variable $ */
function _getGlobalVar(varName) {
  var win = selenium.browserbot.getUserWindow();
    if (win[varName]) {
      return win[varName];
    } else {
      throw undefined;
    }
}

/* allows use of Jquery selectors in pages where jQuery is loaded*/
function jQuery(selector) {
  var jq = _getGlobalVar('jQuery');
    if (typeof jq != 'undefined') {
      return jq(selector);
    } else {
      throw new SeleniumError('jQuery is not defined in the current window');
    }
}
当我想在下面的函数中使用jQuerys trim方法时。我已经阅读了文档,我知道我可以使用jQuery.noConflict;,但这似乎没有什么帮助

Selenium.prototype.doClickSearchTemplate = function (locator, action) {
  $ = _getGlobalVar('jQuery');
  profileToggleButton = null;
  profileName = '';

 var locator = locator || 'id=content';
 var reportBlockContainer = this.page().findElement(locator);

jQuery(reportBlockContainer).find('.reportBlockHeader h2 strong').each(function(index, elem) { 
  profileName = $.trim(jQuery(elem).text());
    if (profileName == action)  
      profileToggleButton = elem.parentNode.previousElementSibling; // previousSibling = jQuery(elem).parent().prev().get(0);
});

  if (profileToggleButton === null)
    throw new SeleniumError("Invalid Search Template Name: " +action);

    this.browserbot.clickElement(profileToggleButton);
};
这导致的问题是,当我单击“播放当前测试用例”时,它将第一次正常运行,调用此函数,执行此函数,然后我的测试将通过,但是当我再次尝试并按下“播放当前测试用例”时,就像按钮被禁用,它不会启动


如果我不调用这个函数,那么一切正常,我不确定它是否与$variable的赋值有关。

通过返回JavaScript解决了这个问题

profileName = jQuery(elem).text();
profileName = profileName.trim();
现在一切都好了