Revision: 681
http://svn.sourceforge.net/jwebunit/?rev=681&view=rev
Author: henryju
Date: 2007-03-13 14:20:12 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Add a new method: getElementTextByXPath. Contributed by Dragan Pazin.
Add a test case.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/XPathTest.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IJWebUnitDialog.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
Modified:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/XPathTest.java
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/XPathTest.java
2007-03-07 18:32:34 UTC (rev 680)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/XPathTest.java
2007-03-13 21:20:12 UTC (rev 681)
@@ -43,4 +43,9 @@
clickElementByXPath("//tr//a[contains(@href,\"next\") and
contains(string(),\"test link\")]");
assertTitleEquals("Next");
}
+
+ public void testGetElementTextByXPath() throws Throwable {
+ beginAt("/testPage.html");
+ assertEquals("test link",
getElementTextByXPath("//tr//a[contains(@href,\"next\")]"));
+ }
}
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IJWebUnitDialog.java
===================================================================
---
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IJWebUnitDialog.java
2007-03-07 18:32:34 UTC (rev 680)
+++
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/api/IJWebUnitDialog.java
2007-03-13 21:20:12 UTC (rev 681)
@@ -688,6 +688,14 @@
String getElementAttributByXPath(String xpath, String attribut);
/**
+ * Get text of the given element.
+ *
+ * @param xpath xpath of the element.
+ */
+ String getElementTextByXPath(String xpath);
+
+
+ /**
* Return true if a given string is contained within the specified element.
*
* @param elementID ID of element to inspect.
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
---
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
2007-03-07 18:32:34 UTC (rev 680)
+++
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
2007-03-13 21:20:12 UTC (rev 681)
@@ -2057,6 +2057,19 @@
return getTestingEngine().getElementAttributByXPath(xpath, attribut);
}
+ /**
+ * Get text of the given element.
+ *
+ * @param xpath xpath of the element.
+ */
+ public String getElementTextByXPath(String xpath){
+ assertElementPresentByXPath(xpath);
+ return getTestingEngine().getElementTextByXPath(xpath);
+ }
+
+
+
+
// Window and Frame Navigation Methods
/**
Modified:
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
===================================================================
---
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
2007-03-07 18:32:34 UTC (rev 680)
+++
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
2007-03-13 21:20:12 UTC (rev 681)
@@ -1672,6 +1672,16 @@
return e.getAttributeValue(attribut);
}
+
+ public String getElementTextByXPath(String xpath) {
+ HtmlElement e = getElementByXPath(xpath);
+ if (e == null)
+ return null;
+ return e.asText();
+ }
+
+
+
/**
* Click the indicated button (input type=button).
*
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development