Author: lfryc(a)redhat.com
Date: 2010-01-13 10:55:46 -0500 (Wed, 13 Jan 2010)
New Revision: 16276
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/resources/jbossqa-extensions.js
Log:
- reimplement getJQueryCount(String selector) to use proper counting way:
$(inDocument).find(selector).length
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java
===================================================================
---
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java 2010-01-13
15:24:41 UTC (rev 16275)
+++
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/java/org/jboss/test/selenium/AbstractSeleniumTestCase.java 2010-01-13
15:55:46 UTC (rev 16276)
@@ -722,22 +722,18 @@
selenium.getEval(evaluate);
}
- /**
- * Returns the count of elements for given jQuery locator.
- * @param locator a jQuery locator that doesn't end with :eq(), :last, :first,
:odd, etc.
- * @return count of elements matching given locator
- */
- public int getJQueryCount(String locator) {
- int count = 0;
- for (int i = 0;; i++) {
- if (selenium.isElementPresent(format(locator + ":eq({0})", i))) {
- count++;
- } else {
- break;
- }
- }
- return count;
- }
+ /**
+ * Returns the count of elements for given jQuery selector
+ *
+ * @param selector
+ * jQuery selector
+ * @return count of elements matching given selector
+ */
+ public int getJQueryCount(String selector) {
+ String evaluate = format("selenium.getJQueryCount(\"{0}\")",
selector.replaceFirst("^jquery=", ""));
+ String result = selenium.getEval(evaluate);
+ return Integer.parseInt(result);
+ }
/**
* Checks if element given by locator is member of CSS class given by
Modified:
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/resources/jbossqa-extensions.js
===================================================================
---
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/resources/jbossqa-extensions.js 2010-01-13
15:24:41 UTC (rev 16275)
+++
branches/community/3.3.X/test-applications/selenium-testing-lib/src/main/resources/jbossqa-extensions.js 2010-01-13
15:55:46 UTC (rev 16276)
@@ -166,6 +166,19 @@
}
/**
+ * Returns the count of elements for given jQuery selector
+ *
+ * @param selector
+ * jQuery selector
+ * @return count of elements matching given selector
+ */
+Selenium.prototype.getJQueryCount = function(selector) {
+ var inDocument = this.browserbot.getDocument();
+ var found = $(inDocument).find(selector);
+ return found.length;
+}
+
+/**
* Gets the text of an element. This works for any element that contains
* text. This command uses either the textContent (Mozilla-like browsers) or
* the innerText (IE-like browsers) of the element, which is the rendered
Show replies by date