[Jsimplebrowser-svn] SF.net SVN: jsimplebrowser: [42] trunk
Status: Alpha
Brought to you by:
rdimarco
|
From: <rdi...@us...> - 2007-08-11 03:21:39
|
Revision: 42
http://jsimplebrowser.svn.sourceforge.net/jsimplebrowser/?rev=42&view=rev
Author: rdimarco
Date: 2007-08-10 20:21:37 -0700 (Fri, 10 Aug 2007)
Log Message:
-----------
First version of selenium client. Not all tests passing yet.
Modified Paths:
--------------
trunk/core/src/main/java/com/software416/jsimplebrowser/Browser.java
trunk/core/src/main/java/com/software416/jsimplebrowser/impl/BrowserImpl.java
trunk/pom.xml
Added Paths:
-----------
trunk/core/src/main/java/com/software416/jsimplebrowser/util/ElementLocator.java
trunk/core/src/test/java/com/software416/jsimplebrowser/util/ElementLocatorTest.java
trunk/core/src/test/resources/elementLocatorTest.html
trunk/selenium-client/
trunk/selenium-client/src/
trunk/selenium-client/src/main/
trunk/selenium-client/src/main/java/
trunk/selenium-client/src/main/java/com/
trunk/selenium-client/src/main/java/com/software416/
trunk/selenium-client/src/main/java/com/software416/jsimplebrowser/
trunk/selenium-client/src/main/java/com/software416/jsimplebrowser/seleniumclient/
trunk/selenium-client/src/main/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClient.java
trunk/selenium-client/src/main/resources/
trunk/selenium-client/src/test/
trunk/selenium-client/src/test/java/
trunk/selenium-client/src/test/java/com/
trunk/selenium-client/src/test/java/com/software416/
trunk/selenium-client/src/test/java/com/software416/jsimplebrowser/
trunk/selenium-client/src/test/java/com/software416/jsimplebrowser/seleniumclient/
trunk/selenium-client/src/test/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClientTest.java
trunk/selenium-client/src/test/resources/
trunk/selenium-client/src/test/resources/tableTest.html
Modified: trunk/core/src/main/java/com/software416/jsimplebrowser/Browser.java
===================================================================
--- trunk/core/src/main/java/com/software416/jsimplebrowser/Browser.java 2007-08-10 19:04:30 UTC (rev 41)
+++ trunk/core/src/main/java/com/software416/jsimplebrowser/Browser.java 2007-08-11 03:21:37 UTC (rev 42)
@@ -1,9 +1,13 @@
package com.software416.jsimplebrowser;
+import java.util.List;
+
public interface Browser {
public static final String MAIN_BROWSER_WINDOW_NAME = "main";
public void open(String url) throws BrowserException;
public void open(String url, String window) throws BrowserException;
public HttpResponse makeXmlHttpRequest(String url, String requestBody) throws BrowserException;
public Window getWindow(String windowName);
+ public void closeWindow(String windowName);
+ public List<String> getWindowNames();
}
Modified: trunk/core/src/main/java/com/software416/jsimplebrowser/impl/BrowserImpl.java
===================================================================
--- trunk/core/src/main/java/com/software416/jsimplebrowser/impl/BrowserImpl.java 2007-08-10 19:04:30 UTC (rev 41)
+++ trunk/core/src/main/java/com/software416/jsimplebrowser/impl/BrowserImpl.java 2007-08-11 03:21:37 UTC (rev 42)
@@ -2,7 +2,9 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.commons.httpclient.HttpClient;
@@ -70,4 +72,12 @@
}
return _browserWindows.get(windowName);
}
+
+ public void closeWindow(String windowName) {
+ _browserWindows.remove(windowName);
+ }
+
+ public List<String> getWindowNames() {
+ return new ArrayList<String>(_browserWindows.keySet());
+ }
}
Added: trunk/core/src/main/java/com/software416/jsimplebrowser/util/ElementLocator.java
===================================================================
--- trunk/core/src/main/java/com/software416/jsimplebrowser/util/ElementLocator.java (rev 0)
+++ trunk/core/src/main/java/com/software416/jsimplebrowser/util/ElementLocator.java 2007-08-11 03:21:37 UTC (rev 42)
@@ -0,0 +1,58 @@
+package com.software416.jsimplebrowser.util;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class ElementLocator {
+ private Log LOG = LogFactory.getLog(ElementLocator.class);
+ private Document _document;
+ public ElementLocator(Document doc) {
+ _document = doc;
+ }
+
+ public Element findElement(String locator) {
+ if (locator.startsWith("//")) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("locator is an XPATH expression");
+ }
+ return locateElementByXPath(locator);
+ }
+ if (locator.startsWith("document.")) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("locator is an javascript expression");
+ }
+ return this.locateElementByDomTraversal(locator);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("locator is an idenitfier");
+ }
+ return this.locateElementByIdentifier(locator);
+ }
+
+ protected Element locateElementByXPath(String locator) {
+ XPath xp = XPathFactory.newInstance().newXPath();
+ try {
+ NodeList nl = (NodeList)xp.evaluate(locator.toUpperCase(), _document.getDocumentElement(), XPathConstants.NODESET);
+ return nl.getLength() > 0 ? (Element)nl.item(0) : null;
+ } catch (XPathExpressionException ex) {
+ LOG.warn("Problem handling XPath : " + locator, ex);
+ return null;
+ }
+ }
+
+ protected Element locateElementByDomTraversal(String locator) {
+ throw new UnsupportedOperationException();
+ }
+
+ protected Element locateElementByIdentifier(String locator) {
+ return _document.getElementById(locator);
+ }
+}
Added: trunk/core/src/test/java/com/software416/jsimplebrowser/util/ElementLocatorTest.java
===================================================================
--- trunk/core/src/test/java/com/software416/jsimplebrowser/util/ElementLocatorTest.java (rev 0)
+++ trunk/core/src/test/java/com/software416/jsimplebrowser/util/ElementLocatorTest.java 2007-08-11 03:21:37 UTC (rev 42)
@@ -0,0 +1,36 @@
+package com.software416.jsimplebrowser.util;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.software416.jsimplebrowser.BrowserException;
+import com.software416.jsimplebrowser.impl.HttpResponseImpl;
+import com.software416.jsimplebrowser.impl.WindowImpl;
+
+public class ElementLocatorTest {
+ @BeforeClass public static void setUpLog() {
+ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
+ System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
+ System.setProperty("org.apache.commons.logging.simplelog.log.com.software416", "debug");
+ }
+
+ @Test public void testElementLocator() throws BrowserException, IOException {
+ WindowImpl w = new WindowImpl(null);
+ HttpResponseImpl ri = new HttpResponseImpl();
+ ri.setResponseBody(IOUtils.toByteArray(Thread.currentThread().getContextClassLoader().getResourceAsStream("elementLocatorTest.html")));
+ w.handleResponse(ri);
+
+ ElementLocator lc = new ElementLocator(w.getDocument());
+
+ assertNotNull(w.getDocument().getElementsByTagName("form"));
+
+ assertNotNull(lc.findElement("//form[1]"));
+ assertNotNull(lc.findElement("//FORM[1]"));
+ assertNotNull(lc.findElement("foo"));
+ }
+}
Added: trunk/core/src/test/resources/elementLocatorTest.html
===================================================================
--- trunk/core/src/test/resources/elementLocatorTest.html (rev 0)
+++ trunk/core/src/test/resources/elementLocatorTest.html 2007-08-11 03:21:37 UTC (rev 42)
@@ -0,0 +1,7 @@
+<html>
+ <body>
+ <form id="foo">
+ <input type="text" id="bar">
+ </form>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2007-08-10 19:04:30 UTC (rev 41)
+++ trunk/pom.xml 2007-08-11 03:21:37 UTC (rev 42)
@@ -69,6 +69,7 @@
<url>http://jsimplebrowser.sourceforge.net/</url>
<modules>
<module>core</module>
+ <module>selenium-client</module>
</modules>
<build>
<defaultGoal>install</defaultGoal>
@@ -159,6 +160,11 @@
<artifactId>commons-httpclient</artifactId>
<version>3.1-rc1</version>
</dependency>
+ <dependency>
+ <groupId>org.openqa.selenium.client-drivers</groupId>
+ <artifactId>selenium-java-client-driver</artifactId>
+ <version>0.9.2-SNAPSHOT</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<reporting>
Property changes on: trunk/selenium-client
___________________________________________________________________
Name: svn:ignore
+ .settings
target
.classpath
.project
Added: trunk/selenium-client/src/main/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClient.java
===================================================================
--- trunk/selenium-client/src/main/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClient.java (rev 0)
+++ trunk/selenium-client/src/main/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClient.java 2007-08-11 03:21:37 UTC (rev 42)
@@ -0,0 +1,643 @@
+package com.software416.jsimplebrowser.seleniumclient;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.collections.MultiHashMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import com.software416.jsimplebrowser.Browser;
+import com.software416.jsimplebrowser.BrowserException;
+import com.software416.jsimplebrowser.Window;
+import com.software416.jsimplebrowser.impl.BrowserImpl;
+import com.software416.jsimplebrowser.util.ElementLocator;
+import com.thoughtworks.selenium.Selenium;
+
+public class SeleniumClient implements Selenium {
+ private static final Log LOG = LogFactory.getLog(SeleniumClient.class);
+ private BrowserImpl _browser;
+ private String _currentWindowName = Browser.MAIN_BROWSER_WINDOW_NAME;
+
+ public void check(String id) {
+ throw new UnsupportedOperationException();
+ }
+ public void click(String id) {
+ throw new UnsupportedOperationException();
+ }
+ public void clickAt(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getHtmlSource() {
+ return getCurrentWindow().getSource();
+ }
+
+ public String getLocation() {
+ return getCurrentWindow().getLocation();
+ }
+
+ public void close() {
+ _browser.closeWindow(_currentWindowName);
+ _currentWindowName = Browser.MAIN_BROWSER_WINDOW_NAME;
+ }
+ public void windowFocus() {
+ // noop (although, I would think a window id/name would come in here.
+ }
+
+ public void windowMaximize() {
+ // noop
+ }
+
+ public String[] getAllButtons() {
+ return getAllElements("//input[@type='button' or @type='submit' or @type = 'reset']/@id");
+ }
+
+ public String[] getAllFields() {
+ return getAllElements("//input[@type='text']/@id");
+ }
+
+ public String[] getAllLinks() {
+ return getAllElements("//a/@id");
+ }
+
+ protected String[] getAllElements(String xpath) {
+ XPath xp = XPathFactory.newInstance().newXPath();
+ NodeList nl;
+ try {
+ nl = (NodeList)xp.evaluate(xpath, getDocument(), XPathConstants.NODESET);
+ } catch (XPathExpressionException ex) {
+ throw new RuntimeException("Developer screwed up the xpath: " + xpath, ex);
+ }
+ List<String> links = new ArrayList<String>();
+ for (int x = 0; x < nl.getLength(); x++) {
+ Attr a = (Attr)nl.item(x);
+ links.add(a.getValue());
+ }
+ return links.toArray(new String[links.size()]);
+ }
+
+ protected Document getDocument() {
+ return getCurrentWindow().getDocument();
+ }
+ private Window getCurrentWindow() {
+ return _browser.getWindow(_currentWindowName);
+ }
+
+ public void createCookie(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void deleteCookie(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String[] getAllWindowIds() {
+ return getAllWindowNames();
+ }
+
+ public String[] getAllWindowNames() {
+ List<String> windowNames = _browser.getWindowNames();
+ return windowNames.toArray(new String[windowNames.size()]);
+ }
+
+ public String[] getAllWindowTitles() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAttribute(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String[] getAttributeFromAllWindows(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getBodyText() {
+ return getDocument().getElementsByTagName("body").item(0).getTextContent();
+ }
+
+ public String getCookie() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public String[] getSelectOptions(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getSelectedId(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String[] getSelectedIds(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getSelectedIndex(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String[] getSelectedIndexes(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getSelectedLabel(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String[] getSelectedLabels(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getSelectedValue(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String[] getSelectedValues(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+ /**
+ * Gets the text from a cell of a table. The cellAddress syntax
+ * tableLocator.row.column, where row and column start at 0.
+ *
+ * @param tableCellAddress a cell address, e.g. "foo.1.4"
+ * @return string the text from the specified cell
+ */
+ public String getTable(String tableCellAddress) {
+ Pattern p = Pattern.compile("(.*)\\.(\\d+)\\.(\\d+)");
+ Matcher m = p.matcher(tableCellAddress);
+ if (!m.matches()) {
+ LOG.warn("Invalid table cell address: " + tableCellAddress);
+ return null;
+ }
+
+ int row,col;
+ try {
+ row = Integer.parseInt(m.group(2));
+ col = Integer.parseInt(m.group(3));
+ } catch (NumberFormatException ex) {
+ LOG.warn("Invalid table cell address: " + tableCellAddress);
+ return null;
+ }
+
+ Element table = new ElementLocator(getDocument()).findElement(m.group(1));
+ if (table != null) {
+ NodeList rows = table.getElementsByTagName("tr");
+ if (row < rows.getLength()) {
+ NodeList cells = ((Element)rows.item(row)).getChildNodes();
+ int cellCount = 0;
+ for (int x = 0; x < cells.getLength(); x++) {
+ if (cells.item(x).getNodeType() == Node.ELEMENT_NODE) {
+ Element cell = (Element)cells.item(x);
+ if (cell.getTagName().equalsIgnoreCase("td") || cell.getTagName().equalsIgnoreCase("th")) {
+ if (cellCount == col) {
+ return cell.getTextContent();
+ } else {
+ cellCount++;
+ }
+ }
+ }
+ }
+
+ } else {
+ LOG.warn("Invalid table cell address: " + tableCellAddress + " table only has " + rows.getLength() + " rows ");
+ }
+ } else {
+ LOG.warn("Could not find table : " + m.group(1));
+ }
+ return null;
+ }
+
+ public String getText(String id) {
+ return getDocument().getElementById(id).getTextContent();
+ }
+
+ public String getTitle() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getValue(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean getWhetherThisFrameMatchFrameExpression(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean getWhetherThisWindowMatchWindowExpression(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Number getXpathCount(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void goBack() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public boolean isChecked(String id) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isEditable(String id) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isElementPresent(String id) {
+ return getDocument().getElementById(id) != null;
+ }
+
+ public boolean isOrdered(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSomethingSelected(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isTextPresent(String text) {
+ return getCurrentWindow().getSource().contains(text);
+ }
+
+ public boolean isVisible(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void open(String url) {
+ try {
+ getCurrentWindow().open(url);
+ } catch (BrowserException ex) {
+ LOG.warn("Problem loading page", ex);
+ }
+ }
+
+ public void openWindow(String windowName, String url) {
+ try {
+ _currentWindowName = windowName;
+ getCurrentWindow().open(url);
+ } catch (BrowserException ex) {
+ LOG.warn("Problem loading page", ex);
+ }
+ }
+
+ public void refresh() {
+ open(getCurrentWindow().getLocation());
+ }
+
+ public void removeAllSelections(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void removeSelection(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void select(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void selectFrame(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void selectWindow(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setBrowserLogLevel(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContext(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void start() {
+ _browser = new BrowserImpl();
+ }
+
+ public void stop() {
+ _browser = null;
+ }
+
+ public void submit(String id) {
+ try {
+ getCurrentWindow().submitForm(id, new MultiHashMap());
+ } catch (BrowserException ex) {
+ LOG.warn("Problem loading page", ex);
+ }
+ }
+
+ public void type(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void typeKeys(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+ public void setTimeout(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void uncheck(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void waitForCondition(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void waitForFrameToLoad(String arg0, String arg1) {
+ // noop
+ }
+
+ public void waitForPageToLoad(String arg0) {
+ // noop
+ }
+
+ //
+ // Currently Unsupported Operations
+ //
+ public void addSelection(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void altKeyDown() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void altKeyUp() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void answerOnNextPrompt(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void captureScreenshot(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void chooseCancelOnNextConfirmation() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void chooseOkOnNextConfirmation() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void controlKeyDown() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void controlKeyUp() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void doubleClick(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void doubleClickAt(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void dragAndDrop(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void dragAndDropToObject(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void dragdrop(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void fireEvent(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getAlert() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getConfirmation() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Number getCursorPosition(String arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Number getElementHeight(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Number getElementIndex(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Number getElementPositionLeft(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Number getElementPositionTop(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Number getElementWidth(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getEval(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getExpression(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Number getMouseSpeed() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public String getPrompt() {
+ throw new UnsupportedOperationException();
+
+ }
+ public void getSpeed() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void highlight(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public boolean isAlertPresent() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isConfirmationPresent() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isPromptPresent() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void keyDown(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void keyPress(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void keyUp(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void metaKeyDown() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void metaKeyUp() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseDown(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseDownAt(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseMove(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseMoveAt(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseOut(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseOver(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseUp(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseUpAt(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setCursorPosition(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setMouseSpeed(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setSpeed(String arg0) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void shiftKeyDown() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void shiftKeyUp() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void waitForPopUp(String arg0, String arg1) {
+ throw new UnsupportedOperationException();
+
+ }
+
+
+}
Added: trunk/selenium-client/src/test/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClientTest.java
===================================================================
--- trunk/selenium-client/src/test/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClientTest.java (rev 0)
+++ trunk/selenium-client/src/test/java/com/software416/jsimplebrowser/seleniumclient/SeleniumClientTest.java 2007-08-11 03:21:37 UTC (rev 42)
@@ -0,0 +1,44 @@
+package com.software416.jsimplebrowser.seleniumclient;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+import com.software416.jsimplebrowser.BrowserException;
+import com.software416.jsimplebrowser.util.HtmlToDomConverter;
+
+public class SeleniumClientTest {
+ @BeforeClass public static void setUpLog() {
+ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
+ System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
+ System.setProperty("org.apache.commons.logging.simplelog.log.com.software416", "debug");
+ }
+
+ @Test public void testElementSearch() throws IOException, BrowserException {
+ SeleniumClient sc = new TestSeleniumClient("");
+ //assertEquals("/ig?hl=en", sc.getTable("//table[1].1.1"));
+ //assertEquals("/ig?hl=en", sc.getTable("foo.1.1"));
+ //assertEquals("Command", sc.getTable("foo.0.0"));
+ assertNull(sc.getTable("foo1.0.0"));
+ assertNull(sc.getTable("foo1.100.100"));
+ assertNull(sc.getTable("foo1.100"));
+ }
+
+ private static class TestSeleniumClient extends SeleniumClient {
+ private Document _document;
+
+ TestSeleniumClient (String resourceLocation) throws IOException, BrowserException {
+ _document = new HtmlToDomConverter().getDocumentFromHtml(IOUtils.toByteArray(Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceLocation)));
+ }
+
+ @Override
+ public Document getDocument() {
+ return _document;
+ }
+ }
+}
Added: trunk/selenium-client/src/test/resources/tableTest.html
===================================================================
--- trunk/selenium-client/src/test/resources/tableTest.html (rev 0)
+++ trunk/selenium-client/src/test/resources/tableTest.html 2007-08-11 03:21:37 UTC (rev 42)
@@ -0,0 +1,42 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>test</title>
+</head>
+<body>
+<table id="foo" cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">test</td></tr>
+</thead><tbody>
+<tr>
+ <th>Command</th>
+ <th>Data</th>
+
+ <th>Optional</th>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/ig?hl=en</td>
+
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>q</td>
+ <td>Java SDK</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+
+ <td>btnG</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>Download Java 2 Platform, Standard Edition, v 1.4.2 (J2SE)</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|