Revision: 566
http://svn.sourceforge.net/jwebunit/?rev=566&view=rev
Author: henryju
Date: 2006-09-21 08:53:30 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
Begin to improve Selenium Dialog. Need works ;)
Modified Paths:
--------------
trunk/jwebunit-selenium-plugin/pom.xml
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
Modified: trunk/jwebunit-selenium-plugin/pom.xml
===================================================================
--- trunk/jwebunit-selenium-plugin/pom.xml 2006-09-21 15:51:56 UTC (rev
565)
+++ trunk/jwebunit-selenium-plugin/pom.xml 2006-09-21 15:53:30 UTC (rev
566)
@@ -29,12 +29,6 @@
<version>0.8.2-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>org.openqa.selenium.server</groupId>
- <artifactId>selenium-server</artifactId>
- <version>0.8.2-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
<version>2.0-SNAPSHOT</version>
Modified:
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
===================================================================
---
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
2006-09-21 15:51:56 UTC (rev 565)
+++
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
2006-09-21 15:53:30 UTC (rev 566)
@@ -4,13 +4,13 @@
******************************************************************************/
package net.sourceforge.jwebunit.selenium;
-import java.io.PrintStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import net.sourceforge.jwebunit.exception.ElementNotFoundException;
import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
-import net.sourceforge.jwebunit.exception.UnableToSetFormException;
import net.sourceforge.jwebunit.html.Table;
-import net.sourceforge.jwebunit.util.ExceptionUtility;
import net.sourceforge.jwebunit.IJWebUnitDialog;
import net.sourceforge.jwebunit.TestContext;
@@ -27,6 +27,10 @@
*
*/
public class SeleniumDialog implements IJWebUnitDialog {
+ /**
+ * Logger for this class.
+ */
+ private static final Log LOGGER = LogFactory.getLog(SeleniumDialog.class);
private Selenium selenium;
@@ -68,38 +72,38 @@
public void clickButton(String buttonId) {
selenium.click("id=buttonId");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void clickButtonWithText(String buttonValueText) {
selenium.click("xpath=" + formSelector() + "//button[contains(.,'" +
buttonValueText + "')]");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void clickElementByXPath(String xpath) {
selenium.click("xpath=" + xpath);
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void clickLink(String anID) {
selenium.click("xpath=//[EMAIL PROTECTED]'" + anID + "']");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void clickLinkWithExactText(String linkText, int index) {
selenium.click("xpath=//a[.//*='" + linkText + "'][" + index + 1 +
"]");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void clickLinkWithImage(String imageFileName, int index) {
selenium.click("xpath=//a[contains(img/@src,'" + imageFileName +
"')]");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void clickLinkWithText(String linkText, int index) {
selenium.click("xpath=//a[contains(.,'" + linkText + "')][" + index + 1
+ "]");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void clickLinkWithTextAfterText(String linkText, String labelText) {
@@ -120,7 +124,9 @@
}
public String[][] getCookies() {
- // TODO Implement getCookies in SeleniumDialog
+ //TODO
+ //FIXME
+ //selenium.getCookie();
throw new UnsupportedOperationException("getCookies");
}
@@ -196,7 +202,7 @@
public void goBack() {
selenium.goBack();
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void gotoFrame(String frameName) {
@@ -324,9 +330,11 @@
}
public boolean hasSubmitButton(String nameOrID) {
+ String xpath = "xpath=" + formSelector() + "//[EMAIL
PROTECTED]'submit' and (@id='"
+ + nameOrID + "' or @name='" + nameOrID + "')]";
+ LOGGER.debug("Execute isElementPresent("+xpath+")");
return selenium
- .isElementPresent("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'submit' and (@id='"
- + nameOrID + "' or @name='" + nameOrID + "')]");
+ .isElementPresent(xpath);
}
public boolean hasResetButton() {
@@ -371,12 +379,12 @@
public void refresh() {
selenium.refresh();
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void reset() {
selenium.click("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'reset']");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void selectOptions(String selectName, String[] optionsValue) {
@@ -395,8 +403,16 @@
}
public void setTextField(String inputName, String text) {
- //TODO Add textarea support
- selenium.type("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'"+inputName+"' and (@type=text or @type=password)]", text);
+ //TODO Add textarea support and file support
+ try {
+ selenium.type("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'"+inputName+"' and (@type='text' or @type='password' or
@type='file')]", text);
+ } catch (SeleniumException e) {
+ try {
+ selenium.type("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'"+inputName+"']", text);
+ } catch(SeleniumException e2) {
+ throw e;
+ }
+ }
}
public void setWorkingForm(String nameOrId, int index) {
@@ -408,17 +424,17 @@
public void submit() {
selenium.click("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'submit']");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void submit(String buttonName, String buttonValue) {
selenium.click("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'submit' and @name='"+buttonName+"' and @value='"+buttonValue+"']");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void submit(String buttonName) {
selenium.click("xpath=" + formSelector() + "//[EMAIL
PROTECTED]'submit' and @name='"+buttonName+"']");
- selenium.waitForPageToLoad(timeout);
+ //selenium.waitForPageToLoad(timeout);
}
public void uncheckCheckbox(String checkBoxName, String value) {
@@ -457,8 +473,7 @@
}
public int getWindowCount() {
- //TODO implement getWindowCount in SeleniumDialog
- throw new UnsupportedOperationException("getWindowCount");
+ return selenium.getAllWindowTitles().length;
}
public void gotoWindow(int windowID) {
Modified:
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
===================================================================
---
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
2006-09-21 15:51:56 UTC (rev 565)
+++
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
2006-09-21 15:53:30 UTC (rev 566)
@@ -28,22 +28,22 @@
TestSuite suite = new TestSuite("Test for
net.sourceforge.jwebunit.selenium");
//$JUnit-BEGIN$
suite.addTestSuite(FormSubmissionTest.class);
- suite.addTestSuite(WebAssertionsTest.class);
- suite.addTestSuite(FramesAndWindowsTest.class);
- suite.addTestSuite(TableAssertionsTest.class);
- suite.addTestSuite(ExpectedTableAssertionsHtmlTest.class);
- suite.addTestSuite(ExpectedTableAssertionsXHtmlTest.class);
- suite.addTestSuite(JavaScriptEventsTest.class);
- suite.addTestSuite(JavaScriptTest.class);
- suite.addTestSuite(HelloWorldTest.class);
- suite.addTestSuite(HtmlParsingTest.class);
- suite.addTestSuite(WebCookieTest.class);
- suite.addTestSuite(TestContextTest.class);
- suite.addTestSuite(FormAssertionsTest.class);
- suite.addTestSuite(NavigationTest.class);
- suite.addTestSuite(XPathTest.class);
- suite.addTestSuite(CharsetTest.class);
- suite.addTestSuite(ButtonAssertionsTest.class);
+// suite.addTestSuite(WebAssertionsTest.class);
+// suite.addTestSuite(FramesAndWindowsTest.class);
+// suite.addTestSuite(TableAssertionsTest.class);
+// suite.addTestSuite(ExpectedTableAssertionsHtmlTest.class);
+// suite.addTestSuite(ExpectedTableAssertionsXHtmlTest.class);
+// suite.addTestSuite(JavaScriptEventsTest.class);
+// suite.addTestSuite(JavaScriptTest.class);
+// suite.addTestSuite(HelloWorldTest.class);
+// suite.addTestSuite(HtmlParsingTest.class);
+// suite.addTestSuite(WebCookieTest.class);
+// suite.addTestSuite(TestContextTest.class);
+// suite.addTestSuite(FormAssertionsTest.class);
+// suite.addTestSuite(NavigationTest.class);
+// suite.addTestSuite(XPathTest.class);
+// suite.addTestSuite(CharsetTest.class);
+// suite.addTestSuite(ButtonAssertionsTest.class);
//$JUnit-END$
return new JettySetup(suite);
}
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