jwebunit-development Mailing List for JWebUnit (Page 5)
Brought to you by:
henryju
You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(98) |
Jul
(45) |
Aug
(49) |
Sep
(90) |
Oct
(28) |
Nov
(18) |
Dec
(17) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(14) |
Feb
(21) |
Mar
(52) |
Apr
(39) |
May
(61) |
Jun
(35) |
Jul
(42) |
Aug
(31) |
Sep
(34) |
Oct
(16) |
Nov
(14) |
Dec
(61) |
| 2006 |
Jan
(39) |
Feb
(11) |
Mar
(29) |
Apr
(29) |
May
(30) |
Jun
(145) |
Jul
(61) |
Aug
(40) |
Sep
(36) |
Oct
(66) |
Nov
(50) |
Dec
(11) |
| 2007 |
Jan
(30) |
Feb
(1) |
Mar
(47) |
Apr
(9) |
May
(36) |
Jun
(13) |
Jul
(7) |
Aug
(5) |
Sep
(6) |
Oct
(3) |
Nov
(11) |
Dec
(36) |
| 2008 |
Jan
(12) |
Feb
|
Mar
(4) |
Apr
(29) |
May
(1) |
Jun
(8) |
Jul
(10) |
Aug
|
Sep
(2) |
Oct
(77) |
Nov
(107) |
Dec
(46) |
| 2009 |
Jan
(17) |
Feb
(13) |
Mar
(27) |
Apr
(5) |
May
(8) |
Jun
(17) |
Jul
(10) |
Aug
(25) |
Sep
(15) |
Oct
(4) |
Nov
(4) |
Dec
(10) |
| 2010 |
Jan
|
Feb
(6) |
Mar
(12) |
Apr
(15) |
May
(4) |
Jun
(5) |
Jul
(9) |
Aug
(5) |
Sep
(5) |
Oct
(63) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(9) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
(14) |
Sep
(15) |
Oct
(11) |
Nov
(1) |
Dec
(2) |
| 2012 |
Jan
(6) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(14) |
Aug
(17) |
Sep
(8) |
Oct
(1) |
Nov
(17) |
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
(13) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(13) |
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
|
|
From: <he...@us...> - 2011-12-30 15:06:45
|
Revision: 934
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=934&view=rev
Author: henryju
Date: 2011-12-30 15:06:39 +0000 (Fri, 30 Dec 2011)
Log Message:
-----------
Remove toolchains as it is not portable
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-28 10:11:30 UTC (rev 933)
+++ trunk/pom.xml 2011-12-30 15:06:39 UTC (rev 934)
@@ -302,27 +302,6 @@
</pluginManagement>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-toolchains-plugin</artifactId>
- <version>1.0</version>
- <executions>
- <execution>
- <phase>validate</phase>
- <goals>
- <goal>toolchain</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <toolchains>
- <jdk>
- <version>1.5</version>
- <vendor>sun</vendor>
- </jdk>
- </toolchains>
- </configuration>
- </plugin>
- <plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
@@ -383,10 +362,15 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
- <version>4.8.2</version>
+ <version>4.10</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <version>1.3.RC2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3.RC2</version>
</dependency>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Sean O'N. <rot...@gm...> - 2011-12-19 20:06:12
|
Here's an amazing thing http://barkadasamisyon.co.uk/inf.php?NewYear Check it! |
|
From: <he...@us...> - 2011-11-28 10:11:44
|
Revision: 933
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=933&view=rev
Author: henryju
Date: 2011-11-28 10:11:30 +0000 (Mon, 28 Nov 2011)
Log Message:
-----------
Update Maven build/plugins + Fix a deadlock in a test with refresh handler
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java
trunk/pom.xml
trunk/src/changes/changes.xml
trunk/src/site/site.xml
Modified: trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java 2011-10-10 15:53:54 UTC (rev 932)
+++ trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java 2011-11-28 10:11:30 UTC (rev 933)
@@ -18,6 +18,8 @@
*/
package net.sourceforge.jwebunit.htmlunit;
+import org.junit.After;
+
import com.gargoylesoftware.htmlunit.ThreadedRefreshHandler;
import com.gargoylesoftware.htmlunit.WaitingRefreshHandler;
import net.sourceforge.jwebunit.tests.JWebUnitAPITestCase;
@@ -109,5 +111,13 @@
.println("[WARN] skipping test [testChangeRefreshHandler] b/c it only applies to HtmlUnitTestEngineImpl");
}
}
+
+ @After
+ public void cleanup() {
+ if (getTestingEngine() instanceof HtmlUnitTestingEngineImpl) {
+ HtmlUnitTestingEngineImpl engine = (HtmlUnitTestingEngineImpl) getTestingEngine();
+ engine.setRefreshHandler(null);
+ }
+ }
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-10-10 15:53:54 UTC (rev 932)
+++ trunk/pom.xml 2011-11-28 10:11:30 UTC (rev 933)
@@ -221,12 +221,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.3.1</version>
+ <version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.9</version>
+ <version>2.10</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -236,7 +236,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
- <version>2.6</version>
+ <version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -283,12 +283,12 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
- <version>1.2</version>
+ <version>1.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
- <version>2.3</version>
+ <version>3.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -433,7 +433,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
- <version>1.3</version>
+ <version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
@@ -447,64 +447,13 @@
</plugins>
</build>
</profile>
- <profile>
- <id>maven-3</id>
- <activation>
- <file>
- <!-- This employs that the basedir expression is only recognized by Maven 3.x (see MNG-2363) -->
- <exists>${basedir}</exists>
- </file>
- </activation>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.0-beta-3</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-descriptor</id>
- <goals>
- <goal>attach-descriptor</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>m2e</id>
- <activation>
- <property>
- <name>m2e.version</name><!-- Activate only when within eclipse -->
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <!-- Set to false to work around Maven Eclipse plugin (m2e) bug MNGECLIPSE-2215 -->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-toolchains-plugin</artifactId>
- <inherited>false</inherited>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
+ <version>2.8</version>
<configuration>
<configLocation>
${basedir}/${topDirectoryLocation}/src/checkstyle/jwebunit-checkstyle.xml
@@ -524,7 +473,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.9</version>
+ <version>2.10</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
@@ -617,7 +566,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
<configuration>
<aggregate>true</aggregate>
<targetJdk>1.5</targetJdk>
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2011-10-10 15:53:54 UTC (rev 932)
+++ trunk/src/changes/changes.xml 2011-11-28 10:11:30 UTC (rev 933)
@@ -32,7 +32,7 @@
<body>
<release version="3.1" date="UNKNOW" description="Cleanup for Webdriver integration">
<action type="update" dev="henryju">
- getPageText() (and all related assertXX methods) now only deals with what is inside <body> element. Previously it was also returning page title for example.
+ getPageText() (and all related assertXX methods) now only deals with what is inside <body> element. Previously it was also returning page title for example.
</action>
<action type="update" dev="henryju">
gotoRootWindow() now goes to the root "frame" in a multi-frame window. Previously it was only by chance.
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2011-10-10 15:53:54 UTC (rev 932)
+++ trunk/src/site/site.xml 2011-11-28 10:11:30 UTC (rev 933)
@@ -22,8 +22,8 @@
<project name="JWebUnit">
<skin>
<groupId>org.apache.maven.skins</groupId>
- <artifactId>maven-stylus-skin</artifactId>
- <version>1.1</version>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.0</version>
</skin>
<bannerLeft>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: SourceForge.net <no...@so...> - 2011-10-18 16:26:45
|
Feature Requests item #2437370, was opened at 2008-12-17 06:05 Message generated for change (Comment added) made by victor-homyakov You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=2437370&group_id=61302 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core API Group: Release 2.2 Status: Open Priority: 3 Private: No Submitted By: Jevon Wright (jevonwright) Assigned to: Jevon Wright (jevonwright) Summary: Failed assertTitleMatches() should include title Initial Comment: If assertTitleMatches() fails, its failure message should include the current page title. ---------------------------------------------------------------------- Comment By: Victor Homyakov (victor-homyakov) Date: 2011-10-18 19:26 Message: Still not fixed? Just public void assertTitleMatch(String regexp) { String title = getTestingEngine().getPageTitle(); assertMatch("Unable to match [" + regexp + "] in title '" + title +"'", regexp, title); } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=2437370&group_id=61302 |
|
From: <he...@us...> - 2011-10-10 15:54:00
|
Revision: 932
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=932&view=rev
Author: henryju
Date: 2011-10-10 15:53:54 +0000 (Mon, 10 Oct 2011)
Log Message:
-----------
Update to Selenium 2.8.0. No need to override HtmlUnitWebElement anymore.
Modified Paths:
--------------
trunk/jwebunit-webdriver-plugin/pom.xml
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
Removed Paths:
-------------
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java
Modified: trunk/jwebunit-webdriver-plugin/pom.xml
===================================================================
--- trunk/jwebunit-webdriver-plugin/pom.xml 2011-10-10 14:51:03 UTC (rev 931)
+++ trunk/jwebunit-webdriver-plugin/pom.xml 2011-10-10 15:53:54 UTC (rev 932)
@@ -30,7 +30,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
- <version>2.7.0</version>
+ <version>2.8.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
- <version>2.7.0</version>
+ <version>2.8.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
Deleted: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java 2011-10-10 14:51:03 UTC (rev 931)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java 2011-10-10 15:53:54 UTC (rev 932)
@@ -1,38 +0,0 @@
-/**
- * Copyright (c) 2011, JWebUnit team.
- *
- * This file is part of JWebUnit.
- *
- * JWebUnit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * JWebUnit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
- */
-package net.sourceforge.jwebunit.webdriver;
-
-import org.openqa.selenium.Capabilities;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.htmlunit.HtmlUnitDriver;
-
-
-public class FixedHtmlUnitDriver extends HtmlUnitDriver {
-
- public FixedHtmlUnitDriver(Capabilities capabilities) {
- super(capabilities);
- }
-
- protected WebElement newHtmlUnitWebElement(HtmlElement element) {
- return new FixedHtmlUnitWebElement(this, element);
- }
-
-}
Deleted: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java 2011-10-10 14:51:03 UTC (rev 931)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java 2011-10-10 15:53:54 UTC (rev 932)
@@ -1,83 +0,0 @@
-/**
- * Copyright (c) 2011, JWebUnit team.
- *
- * This file is part of JWebUnit.
- *
- * JWebUnit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * JWebUnit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
- */
-package net.sourceforge.jwebunit.webdriver;
-
-import com.gargoylesoftware.htmlunit.html.DomElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlSelect;
-import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
-import java.net.MalformedURLException;
-import java.util.List;
-
-import com.gargoylesoftware.htmlunit.html.HtmlInput;
-import com.gargoylesoftware.htmlunit.html.HtmlOption;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import org.openqa.selenium.htmlunit.HtmlUnitDriver;
-
-import org.openqa.selenium.htmlunit.HtmlUnitWebElement;
-
-/**
- * Fix for issue http://code.google.com/p/selenium/issues/detail?id=2295
- *
- * @author julien, 23 sept. 2011
- */
-public class FixedHtmlUnitWebElement extends HtmlUnitWebElement {
-
- public FixedHtmlUnitWebElement(HtmlUnitDriver parent, HtmlElement element) {
- super(parent, element);
- }
-
- @Override
- public boolean isSelected() {
- assertElementNotStale();
-
- if (element instanceof HtmlInput) {
- return ((HtmlInput) element).isChecked();
- }
- else if (element instanceof HtmlOption) {
- return ((HtmlOption) element).isSelected();
- }
-
- throw new UnsupportedOperationException("Unable to determine if element is selected. Tag name is: " + element.getTagName());
- }
-
- @Override
- public String getAttribute(String name) {
- assertElementNotStale();
-
- final String lowerName = name.toLowerCase();
-
- if (element instanceof HtmlOption && "selected".equals(lowerName)) {
- return ((HtmlOption) element).isSelected() ? "true" : null;
- }
-
- if ("value".equals(lowerName)) {
- if (element instanceof HtmlTextArea) {
- return ((HtmlTextArea) element).getText();
- }
-
- if (element instanceof HtmlOption) {
- return ((HtmlOption) element).getValueAttribute();
- }
- }
-
- return super.getAttribute(name);
- }
-}
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-10-10 14:51:03 UTC (rev 931)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-10-10 15:53:54 UTC (rev 932)
@@ -117,7 +117,7 @@
capabilities.setBrowserName("htmlunit");
capabilities.setVersion("firefox");
- driver = new FixedHtmlUnitDriver(capabilities);
+ driver = new HtmlUnitDriver(capabilities);
//Reset form
formIdent = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-10-10 14:51:10
|
Revision: 931
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=931&view=rev
Author: henryju
Date: 2011-10-10 14:51:03 +0000 (Mon, 10 Oct 2011)
Log Message:
-----------
Simplify retrieve of the response body according to browsermob guys.
Modified Paths:
--------------
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-10-04 08:35:15 UTC (rev 930)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-10-10 14:51:03 UTC (rev 931)
@@ -18,15 +18,8 @@
*/
package net.sourceforge.jwebunit.webdriver;
-import org.apache.http.conn.BasicManagedEntity;
-
-import com.gargoylesoftware.htmlunit.util.NameValuePair;
-
-import java.io.ByteArrayInputStream;
-
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebResponse;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -53,17 +46,15 @@
import net.sourceforge.jwebunit.javascript.JavascriptConfirm;
import net.sourceforge.jwebunit.javascript.JavascriptPrompt;
import net.sourceforge.jwebunit.util.TestContext;
-import org.apache.commons.io.input.ProxyInputStream;
+import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
-import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpStatus;
-import org.apache.http.entity.HttpEntityWrapper;
-import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.entity.BufferedHttpEntity;
import org.apache.http.protocol.HttpContext;
import org.apache.regexp.RE;
import org.apache.regexp.RESyntaxException;
@@ -102,7 +93,6 @@
private static final int DEFAULT_PORT = 8183;
private static final Random RANDOM = new Random();
private HttpResponse response;
- private BasicBufferedHttpEntity entity;
// The xpath string that identifie the current form
// ie : @name='myForm'
private String formIdent;
@@ -167,15 +157,8 @@
proxyServer.start();
proxyServer.addResponseInterceptor(new HttpResponseInterceptor() {
public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
+ response.setEntity(new BufferedHttpEntity(response.getEntity()));
WebDriverTestingEngineImpl.this.response = response;
- if (response instanceof BasicHttpResponse) {
- BasicHttpResponse basicResponse = (BasicHttpResponse) response;
- WebDriverTestingEngineImpl.this.entity = new BasicBufferedHttpEntity(response.getEntity());
- basicResponse.setEntity(WebDriverTestingEngineImpl.this.entity);
- }
- else {
- logger.error("Response is of type {}. Impossible to buffer content.", response.getClass().getSimpleName());
- }
}
});
proxyServer.addRequestInterceptor(new HttpRequestInterceptor() {
@@ -197,70 +180,6 @@
throw new RuntimeException("Unable to start BrowserMob proxy after " + TRY_COUNT + " retries");
}
- private class BasicBufferedHttpEntity extends HttpEntityWrapper {
-
- private BufferedInputStream bis;
-
- public BasicBufferedHttpEntity(HttpEntity wrapped) {
- super(wrapped);
- }
-
- @Override
- public InputStream getContent() throws IOException {
- if (bis == null) {
- bis = new BufferedInputStream(super.getContent());
- }
- return bis;
- }
-
- public byte[] getBufferedContent() {
- return bis.getBuffer();
- }
-
- }
-
- private class BufferedInputStream extends ProxyInputStream {
-
- private ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
- public BufferedInputStream(InputStream proxy) {
- super(proxy);
- }
-
-
- public byte[] getBuffer() {
- return bos.toByteArray();
- }
-
- @Override
- public int read() throws IOException {
- int b = super.read();
- if (b != -1) {
- bos.write(b);
- }
- return b;
- }
-
- @Override
- public int read(byte[] array) throws IOException {
- int len = super.read(array);
- if (len > 0) {
- bos.write(array, 0, len);
- }
- return len;
- }
-
- @Override
- public int read(byte[] array, int off, int len) throws IOException {
- int len2 = super.read(array, off, len);
- if (len2 > 0) {
- bos.write(array, 0, len2);
- }
- return len2;
- }
-
- }
-
private static int getRandomPort() {
synchronized (RANDOM) {
return DEFAULT_PORT + RANDOM.nextInt(1000);
@@ -849,18 +768,12 @@
if (response.getEntity().getContentEncoding() != null) {
encoding = response.getEntity().getContentEncoding().getValue();
}
-
- if (response.getEntity() instanceof BasicBufferedHttpEntity) {
- try {
- return new String(((BasicBufferedHttpEntity) response.getEntity()).getBufferedContent(),
- encoding);
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
+
+ try {
+ return IOUtils.toString(response.getEntity().getContent(), encoding);
}
- else {
- return driver.getPageSource();
+ catch (IOException e) {
+ throw new RuntimeException(e);
}
}
@@ -873,14 +786,21 @@
}
public InputStream getInputStream() {
- if (entity != null) {
- return new ByteArrayInputStream(entity.getBufferedContent());
+ try {
+ return response.getEntity().getContent();
}
- throw new UnsupportedOperationException("Not supported yet.");
+ catch (Exception e) {
+ throw new TestingEngineResponseException(e);
+ }
}
public InputStream getInputStream(URL url) throws TestingEngineResponseException {
- throw new UnsupportedOperationException("Not supported yet.");
+ try {
+ return url.openStream();//TODO support proxy
+ }
+ catch (IOException e) {
+ throw new TestingEngineResponseException(e);
+ }
}
public boolean hasTable(String tableSummaryNameOrId) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: SourceForge.net <no...@so...> - 2011-10-05 12:55:42
|
Support Requests item #3111426, was opened at 2010-11-18 11:34 Message generated for change (Comment added) made by henryju You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497983&aid=3111426&group_id=61302 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed Priority: 5 Private: No Submitted By: Franck Benault (fbenault) Assigned to: Nobody/Anonymous (nobody) Summary: JWebUnit 2.5 TestEngineREsponseException -1 httpStatusCode Initial Comment: I have in my project a small regression between JWebUnit 2.4 to 2.5 TestEngineResponseException does not contain the good httpStatusCode the method getHttpStatusCode returns -1 whereas the real http error is 403 ---------------------------------------------------------------------- >Comment By: Julien HENRY (henryju) Date: 2011-10-05 14:55 Message: Please open a bug with a test case. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497983&aid=3111426&group_id=61302 |
|
From: SourceForge.net <no...@so...> - 2011-10-05 12:54:24
|
Feature Requests item #1513852, was opened at 2006-06-28 11:13 Message generated for change (Comment added) made by henryju You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=1513852&group_id=61302 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: None Group: None >Status: Closed Priority: 1 Private: No Submitted By: Ron Piterman (gegenteil) Assigned to: Nobody/Anonymous (nobody) Summary: Remove JUnit dependency Initial Comment: As testNG is getting more and more attention and many use it instead of JUnit, it would be great if one could also have a unit framework "plugin", so one could use jwebunit with testNG without having to put junit on the classpath. ---------------------------------------------------------------------- >Comment By: Julien HENRY (henryju) Date: 2011-10-05 14:54 Message: Closing this one for now. JWebUnit IS a JUnit based framework... ---------------------------------------------------------------------- Comment By: Jevon Wright (jevonwright) Date: 2008-10-28 23:31 Message: Yeah I haven't seen any projects use TestNG. But after some investigation, it looks like you can automatically convert JUnit tests into TestNG tests, and you can do this as part of an Ant task [1], so it can be automated -- so I don't think we need to remove the JUnit dependency from JWebUnit. [1]: http://testng.org/doc/migrating.html ---------------------------------------------------------------------- Comment By: Julien HENRY (henryju) Date: 2008-10-28 14:18 Message: Nope. I tried to remove JUnit dependency but it is very difficult because of assertion mecanism. After all, JWebUnit is by nature based on JUnit... ---------------------------------------------------------------------- Comment By: Jevon Wright (jevonwright) Date: 2008-10-28 13:42 Message: Did anything happen on the devel list about this topic, or can we close this? ---------------------------------------------------------------------- Comment By: Julien HENRY (henryju) Date: 2006-06-29 18:10 Message: Logged In: YES user_id=1235926 We will discuss this idea on devel mailing list. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=1513852&group_id=61302 |
|
From: SourceForge.net <no...@so...> - 2011-10-05 12:38:52
|
Feature Requests item #1494325, was opened at 2006-05-24 16:07 Message generated for change (Comment added) made by henryju You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=1494325&group_id=61302 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core API Group: Release 2.1 >Status: Closed Priority: 3 Private: No Submitted By: Jeffrey W. Badorek (ytsedt) Assigned to: Jevon Wright (jevonwright) Summary: Consider commons logging instead of log4j Initial Comment: I would like to request that commons logging be used instead of log4j. That way, logging could be done with log4j, jdk 1.4+, or whatever. ---------------------------------------------------------------------- >Comment By: Julien HENRY (henryju) Date: 2011-10-05 14:38 Message: I'm closing this one as slf4j is used for a long time now. ---------------------------------------------------------------------- Comment By: Julien HENRY (henryju) Date: 2008-01-18 09:08 Message: Logged In: YES user_id=1235926 Originator: NO In fact, slf4j would be much better. ---------------------------------------------------------------------- Comment By: Julien HENRY (henryju) Date: 2006-05-24 16:25 Message: Logged In: YES user_id=1235926 Goog idea. I will do this. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=1494325&group_id=61302 |
|
From: SourceForge.net <no...@so...> - 2011-10-05 12:36:52
|
Feature Requests item #2837745, was opened at 2009-08-14 18:14 Message generated for change (Comment added) made by henryju You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=2837745&group_id=61302 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core API Group: Release 3.0 >Status: Closed Priority: 5 Private: No Submitted By: Clint Kim (kimson1st) Assigned to: Julien HENRY (henryju) Summary: Add explicit support for JUnit 4 Initial Comment: It seems all the assertions were made using JUnit 3.x framework. JWebUnit should support JUnit 4 assertions (org.junit.Assert.*). Maybe create WebTesterJUnit4 class? Thanks. ---------------------------------------------------------------------- >Comment By: Julien HENRY (henryju) Date: 2011-10-05 14:36 Message: Implemented in JWebUnit 3.0. See documentation on web site. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497985&aid=2837745&group_id=61302 |
|
From: SourceForge.net <no...@so...> - 2011-10-05 12:35:00
|
Bugs item #2436699, was opened at 2008-12-17 02:50 Message generated for change (Comment added) made by henryju You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497982&aid=2436699&group_id=61302 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core API >Group: Release 3.1 >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Jevon Wright (jevonwright) Assigned to: Jevon Wright (jevonwright) Summary: JWebUnit test cases are not self-contained Initial Comment: JUnit tests should be completely self contained -- that is, you can run any test suite, test case or test method individually and it will test fine. However the JWebUnit tests do not meet this requirement, as the Jetty initialisation is done before the test cases are run?, so individual test cases cannot run (e.g. through Eclipse). This would be helpful for debugging test cases. ---------------------------------------------------------------------- >Comment By: Julien HENRY (henryju) Date: 2011-10-05 14:34 Message: Fixed in trunk. Now it is possible to run each test individually. In Eclipse, because we are using a shared test suite, you should first run the full test suite, then you can re-run individual test case. ---------------------------------------------------------------------- Comment By: Julien HENRY (henryju) Date: 2010-10-19 12:04 Message: The problem is tests are in a separate module to allow easy sharing between htmlunit and selenium testing engines. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497982&aid=2436699&group_id=61302 |
|
From: <he...@us...> - 2011-10-04 08:35:21
|
Revision: 930
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=930&view=rev
Author: henryju
Date: 2011-10-04 08:35:15 +0000 (Tue, 04 Oct 2011)
Log Message:
-----------
Fix version.
Modified Paths:
--------------
branches/jwebunit-3.0.x/jwebunit-code-generator/pom.xml
branches/jwebunit-3.0.x/jwebunit-commons-tests/pom.xml
branches/jwebunit-3.0.x/jwebunit-core/pom.xml
branches/jwebunit-3.0.x/jwebunit-htmlunit-plugin/pom.xml
branches/jwebunit-3.0.x/jwebunit-selenium-plugin/pom.xml
branches/jwebunit-3.0.x/pom.xml
Modified: branches/jwebunit-3.0.x/jwebunit-code-generator/pom.xml
===================================================================
--- branches/jwebunit-3.0.x/jwebunit-code-generator/pom.xml 2011-10-04 08:25:53 UTC (rev 929)
+++ branches/jwebunit-3.0.x/jwebunit-code-generator/pom.xml 2011-10-04 08:35:15 UTC (rev 930)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: branches/jwebunit-3.0.x/jwebunit-commons-tests/pom.xml
===================================================================
--- branches/jwebunit-3.0.x/jwebunit-commons-tests/pom.xml 2011-10-04 08:25:53 UTC (rev 929)
+++ branches/jwebunit-3.0.x/jwebunit-commons-tests/pom.xml 2011-10-04 08:35:15 UTC (rev 930)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: branches/jwebunit-3.0.x/jwebunit-core/pom.xml
===================================================================
--- branches/jwebunit-3.0.x/jwebunit-core/pom.xml 2011-10-04 08:25:53 UTC (rev 929)
+++ branches/jwebunit-3.0.x/jwebunit-core/pom.xml 2011-10-04 08:35:15 UTC (rev 930)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: branches/jwebunit-3.0.x/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- branches/jwebunit-3.0.x/jwebunit-htmlunit-plugin/pom.xml 2011-10-04 08:25:53 UTC (rev 929)
+++ branches/jwebunit-3.0.x/jwebunit-htmlunit-plugin/pom.xml 2011-10-04 08:35:15 UTC (rev 930)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: branches/jwebunit-3.0.x/jwebunit-selenium-plugin/pom.xml
===================================================================
--- branches/jwebunit-3.0.x/jwebunit-selenium-plugin/pom.xml 2011-10-04 08:25:53 UTC (rev 929)
+++ branches/jwebunit-3.0.x/jwebunit-selenium-plugin/pom.xml 2011-10-04 08:35:15 UTC (rev 930)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: branches/jwebunit-3.0.x/pom.xml
===================================================================
--- branches/jwebunit-3.0.x/pom.xml 2011-10-04 08:25:53 UTC (rev 929)
+++ branches/jwebunit-3.0.x/pom.xml 2011-10-04 08:35:15 UTC (rev 930)
@@ -3,7 +3,7 @@
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit</artifactId>
<name>JWebUnit</name>
- <version>3.0</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
JWebUnit is a Java framework that facilitates creation of
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-10-04 08:26:03
|
Revision: 929
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=929&view=rev
Author: henryju
Date: 2011-10-04 08:25:53 +0000 (Tue, 04 Oct 2011)
Log Message:
-----------
Create a branch for minor fixes
Added Paths:
-----------
branches/jwebunit-3.0.x/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-10-04 08:23:00
|
Revision: 928
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=928&view=rev
Author: henryju
Date: 2011-10-04 08:22:53 +0000 (Tue, 04 Oct 2011)
Log Message:
-----------
Update to Selenium 2.7.0. Fix file headers.
Modified Paths:
--------------
trunk/jwebunit-webdriver-plugin/pom.xml
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
trunk/jwebunit-webdriver-plugin/src/site/site.xml
trunk/jwebunit-webdriver-plugin/src/site/xdoc/index.xml
trunk/jwebunit-webdriver-plugin/src/test/java/net/sourceforge/jwebunit/webdriver/JWebUnitTest.java
Modified: trunk/jwebunit-webdriver-plugin/pom.xml
===================================================================
--- trunk/jwebunit-webdriver-plugin/pom.xml 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/pom.xml 2011-10-04 08:22:53 UTC (rev 928)
@@ -17,7 +17,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
- <skip>true</skip>
</configuration>
</plugin>
</plugins>
@@ -31,7 +30,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
- <version>2.6.0</version>
+ <version>2.7.0</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
@@ -42,7 +41,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
- <version>2.6.0</version>
+ <version>2.7.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java 2011-10-04 08:22:53 UTC (rev 928)
@@ -1,3 +1,21 @@
+/**
+ * Copyright (c) 2011, JWebUnit team.
+ *
+ * This file is part of JWebUnit.
+ *
+ * JWebUnit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JWebUnit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
+ */
package net.sourceforge.jwebunit.webdriver;
import org.openqa.selenium.Capabilities;
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java 2011-10-04 08:22:53 UTC (rev 928)
@@ -1,3 +1,21 @@
+/**
+ * Copyright (c) 2011, JWebUnit team.
+ *
+ * This file is part of JWebUnit.
+ *
+ * JWebUnit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JWebUnit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
+ */
package net.sourceforge.jwebunit.webdriver;
import com.gargoylesoftware.htmlunit.html.DomElement;
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java 2011-10-04 08:22:53 UTC (rev 928)
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010, JWebUnit team.
+ * Copyright (c) 2011, JWebUnit team.
*
* This file is part of JWebUnit.
*
@@ -16,7 +16,6 @@
* You should have received a copy of the GNU Lesser General Public License
* along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
*/
-
/**
*
*/
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-10-04 08:22:53 UTC (rev 928)
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010, JWebUnit team.
+ * Copyright (c) 2011, JWebUnit team.
*
* This file is part of JWebUnit.
*
Modified: trunk/jwebunit-webdriver-plugin/src/site/site.xml
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/site/site.xml 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/src/site/site.xml 2011-10-04 08:22:53 UTC (rev 928)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
- Copyright (c) 2010, JWebUnit team.
+ Copyright (c) 2011, JWebUnit team.
This file is part of JWebUnit.
@@ -19,7 +19,6 @@
along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
-->
-
<project name="JWebUnit">
<body>
<menu ref="reports" />
Modified: trunk/jwebunit-webdriver-plugin/src/site/xdoc/index.xml
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/site/xdoc/index.xml 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/src/site/xdoc/index.xml 2011-10-04 08:22:53 UTC (rev 928)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
- Copyright (c) 2010, JWebUnit team.
+ Copyright (c) 2011, JWebUnit team.
This file is part of JWebUnit.
@@ -19,7 +19,6 @@
along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
-->
-
<document>
<properties>
<author email="henryju.at.users.sourceforge.net">Julien HENRY</author>
Modified: trunk/jwebunit-webdriver-plugin/src/test/java/net/sourceforge/jwebunit/webdriver/JWebUnitTest.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/test/java/net/sourceforge/jwebunit/webdriver/JWebUnitTest.java 2011-09-23 15:35:23 UTC (rev 927)
+++ trunk/jwebunit-webdriver-plugin/src/test/java/net/sourceforge/jwebunit/webdriver/JWebUnitTest.java 2011-10-04 08:22:53 UTC (rev 928)
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2010, JWebUnit team.
+ * Copyright (c) 2011, JWebUnit team.
*
* This file is part of JWebUnit.
*
@@ -16,7 +16,6 @@
* You should have received a copy of the GNU Lesser General Public License
* along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
*/
-
package net.sourceforge.jwebunit.webdriver;
import org.junit.AfterClass;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: SourceForge.net <no...@so...> - 2011-09-29 15:50:23
|
Patches item #3415400, was opened at 2011-09-29 16:50 Message generated for change (Tracker Item Submitted) made by xelah1 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497984&aid=3415400&group_id=61302 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Alex (xelah1) Assigned to: Nobody/Anonymous (nobody) Summary: Patch to allow SSL validation to be turned off Initial Comment: Test servers often have self-signed SSL certificates, but JWebUnit refuses to talk to them. My code to register a EasySSLProtocolSocketFactory() stopped working with release 3.0, so I patched JWebUnit to provide a way to turn off certificate validation. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=497984&aid=3415400&group_id=61302 |
|
From: <he...@us...> - 2011-09-23 15:35:30
|
Revision: 927
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=927&view=rev
Author: henryju
Date: 2011-09-23 15:35:23 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Fix xpath expressions and getParent()
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2011-09-23 15:05:27 UTC (rev 926)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2011-09-23 15:35:23 UTC (rev 927)
@@ -78,7 +78,7 @@
/**
* Test parent, child methods
*/
- @Test public void testChildren() {
+ @Test public void testChildrenAndParent() {
assertElementPresent("first");
IElement element = getElementById("first");
assertEquals(element.getName(), "li");
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java 2011-09-23 15:05:27 UTC (rev 926)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java 2011-09-23 15:35:23 UTC (rev 927)
@@ -95,7 +95,7 @@
* @see net.sourceforge.jwebunit.api.IElement#getParent()
*/
public IElement getParent() {
- return new WebDriverElementImpl(element.findElement(By.xpath("//parent::*")));
+ return new WebDriverElementImpl(element.findElement(By.xpath("parent::*")));
}
/*
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-09-23 15:05:27 UTC (rev 926)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-09-23 15:35:23 UTC (rev 927)
@@ -540,7 +540,7 @@
}
public String[] getSelectOptionValues(String selectName, int index) {
- Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + " and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
ArrayList<String> result = new ArrayList<String>();
for (WebElement opt : select.getOptions()) {
result.add(opt.getAttribute("value"));
@@ -563,7 +563,7 @@
}
public String[] getSelectedOptions(String selectName, int index) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
return getSelectedOptions(select);
}
@@ -586,22 +586,22 @@
}
public String getSelectOptionLabelForValue(String selectName, String optionValue) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "']", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "]", true, true));
return getSelectOptionLabelForValue(select, optionValue);
}
public String getSelectOptionLabelForValue(String selectName, int index, String optionValue) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
return getSelectOptionLabelForValue(select, optionValue);
}
public String getSelectOptionValueForLabel(String selectName, String optionLabel) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "']", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "]", true, true));
return getSelectOptionValueForLabel(select, optionLabel);
}
public String getSelectOptionValueForLabel(String selectName, int index, String optionLabel) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
return getSelectOptionValueForLabel(select, optionLabel);
}
@@ -610,7 +610,7 @@
}
public void selectOptions(String selectName, int index, String[] optionValues) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
if (!select.isMultiple() && optionValues.length > 1)
throw new RuntimeException("Multiselect not enabled");
for (String option : optionValues) {
@@ -634,7 +634,7 @@
}
public void unselectOptions(String selectName, int index, String[] optionValues) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
if (!select.isMultiple() && optionValues.length > 1)
throw new RuntimeException("Multiselect not enabled");
for (String option : optionValues) {
@@ -662,7 +662,7 @@
}
public boolean hasSelectOption(String selectName, int index, String optionLabel) {
- Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + " and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
for (WebElement opt : select.getOptions()) {
if (opt.getText().equals(optionLabel)) {
return true;
@@ -672,7 +672,7 @@
}
public boolean hasSelectOptionValue(String selectName, int index, String optionValue) {
- Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + " and position()=" + (index + 1) + "]", true, true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + "][" + (index + 1) + "]", true, true));
for (WebElement opt : select.getOptions()) {
if (opt.getAttribute("value").equals(optionValue)) {
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 15:05:37
|
Revision: 926
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=926&view=rev
Author: henryju
Date: 2011-09-23 15:05:27 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Remove duplicate slf4j implementation.
Modified Paths:
--------------
trunk/jwebunit-webdriver-plugin/pom.xml
Modified: trunk/jwebunit-webdriver-plugin/pom.xml
===================================================================
--- trunk/jwebunit-webdriver-plugin/pom.xml 2011-09-23 15:03:33 UTC (rev 925)
+++ trunk/jwebunit-webdriver-plugin/pom.xml 2011-09-23 15:05:27 UTC (rev 926)
@@ -81,6 +81,10 @@
<artifactId>org.apache.commons</artifactId>
<groupId>commons-io</groupId>
</exclusion>
+ <exclusion>
+ <artifactId>slf4j-jdk14</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 15:03:39
|
Revision: 925
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=925&view=rev
Author: henryju
Date: 2011-09-23 15:03:33 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Improve some tests.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/Frames.html
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java 2011-09-23 14:56:50 UTC (rev 924)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/CustomTesterTest.java 2011-09-23 15:03:33 UTC (rev 925)
@@ -23,6 +23,9 @@
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
import static net.sourceforge.jwebunit.junit.JWebUnit.setCustomTester;
+
+import org.junit.Before;
+
import net.sourceforge.jwebunit.junit.WebTester;
import org.junit.After;
@@ -57,6 +60,7 @@
}
+ @Before
public void setUp() throws Exception {
setCustomTester(new MyWebTester());
super.setUp();
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java 2011-09-23 14:56:50 UTC (rev 924)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java 2011-09-23 15:03:33 UTC (rev 925)
@@ -24,6 +24,8 @@
import java.io.FileWriter;
import java.io.IOException;
+import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
+
import org.junit.Test;
import static net.sourceforge.jwebunit.junit.JWebUnit.*;
@@ -262,11 +264,10 @@
public void testInvalidButton() {
beginAt("/InvalidActionForm.html");
try {
- submit("button1");
- fail("Should have failed because the target page does not exist");
- } catch (RuntimeException e) {
- // TODO Have a better way to know if 404 happened
- assertTrue("Should return 404 error", true);
+ submit("button1");
+ fail("A TestingEngineResponseException was expected.");
+ } catch (TestingEngineResponseException e) {
+ assertEquals(404, e.getHttpStatusCode());
}
}
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/Frames.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/Frames.html 2011-09-23 14:56:50 UTC (rev 924)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/Frames.html 2011-09-23 15:03:33 UTC (rev 925)
@@ -19,7 +19,7 @@
-->
<html>
-<head></head>
+<head><title>Frameset</title></head>
<frameset rows="33%, 33%, 33%">
<frame id="frame1" name="TopFrame" src="TopFrame.html">
<frame id="frame2" name="ContentFrame" src="ContentFrame.html">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 14:56:58
|
Revision: 924
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=924&view=rev
Author: henryju
Date: 2011-09-23 14:56:50 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Lot of work on WebDriver testing engine. Many tests are passing.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/resources/logback-test.xml
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
trunk/jwebunit-webdriver-plugin/src/test/java/net/sourceforge/jwebunit/webdriver/JWebUnitTest.java
Added Paths:
-----------
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java
Removed Paths:
-------------
trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebdriverElementImpl.java
Modified: trunk/jwebunit-commons-tests/src/main/resources/logback-test.xml
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/logback-test.xml 2011-09-23 14:52:27 UTC (rev 923)
+++ trunk/jwebunit-commons-tests/src/main/resources/logback-test.xml 2011-09-23 14:56:50 UTC (rev 924)
@@ -40,6 +40,8 @@
<logger name="org.eclipse.jetty" level="ERROR"/>
<logger name="ch.qos.logback" level="ERROR"/>
+
+ <logger name="org.browsermob.proxy" level="ERROR"/>
<root level="DEBUG">
<appender-ref ref="consoleAppender"/>
Added: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java (rev 0)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java 2011-09-23 14:56:50 UTC (rev 924)
@@ -0,0 +1,20 @@
+package net.sourceforge.jwebunit.webdriver;
+
+import org.openqa.selenium.Capabilities;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.htmlunit.HtmlUnitDriver;
+
+
+public class FixedHtmlUnitDriver extends HtmlUnitDriver {
+
+ public FixedHtmlUnitDriver(Capabilities capabilities) {
+ super(capabilities);
+ }
+
+ protected WebElement newHtmlUnitWebElement(HtmlElement element) {
+ return new FixedHtmlUnitWebElement(this, element);
+ }
+
+}
Property changes on: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitDriver.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java (rev 0)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java 2011-09-23 14:56:50 UTC (rev 924)
@@ -0,0 +1,65 @@
+package net.sourceforge.jwebunit.webdriver;
+
+import com.gargoylesoftware.htmlunit.html.DomElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSelect;
+import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
+import java.net.MalformedURLException;
+import java.util.List;
+
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlOption;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import org.openqa.selenium.htmlunit.HtmlUnitDriver;
+
+import org.openqa.selenium.htmlunit.HtmlUnitWebElement;
+
+/**
+ * Fix for issue http://code.google.com/p/selenium/issues/detail?id=2295
+ *
+ * @author julien, 23 sept. 2011
+ */
+public class FixedHtmlUnitWebElement extends HtmlUnitWebElement {
+
+ public FixedHtmlUnitWebElement(HtmlUnitDriver parent, HtmlElement element) {
+ super(parent, element);
+ }
+
+ @Override
+ public boolean isSelected() {
+ assertElementNotStale();
+
+ if (element instanceof HtmlInput) {
+ return ((HtmlInput) element).isChecked();
+ }
+ else if (element instanceof HtmlOption) {
+ return ((HtmlOption) element).isSelected();
+ }
+
+ throw new UnsupportedOperationException("Unable to determine if element is selected. Tag name is: " + element.getTagName());
+ }
+
+ @Override
+ public String getAttribute(String name) {
+ assertElementNotStale();
+
+ final String lowerName = name.toLowerCase();
+
+ if (element instanceof HtmlOption && "selected".equals(lowerName)) {
+ return ((HtmlOption) element).isSelected() ? "true" : null;
+ }
+
+ if ("value".equals(lowerName)) {
+ if (element instanceof HtmlTextArea) {
+ return ((HtmlTextArea) element).getText();
+ }
+
+ if (element instanceof HtmlOption) {
+ return ((HtmlOption) element).getValueAttribute();
+ }
+ }
+
+ return super.getAttribute(name);
+ }
+}
Property changes on: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/FixedHtmlUnitWebElement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java (from rev 913, trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebdriverElementImpl.java)
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java (rev 0)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java 2011-09-23 14:56:50 UTC (rev 924)
@@ -0,0 +1,198 @@
+/**
+ * Copyright (c) 2010, JWebUnit team.
+ *
+ * This file is part of JWebUnit.
+ *
+ * JWebUnit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JWebUnit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *
+ */
+package net.sourceforge.jwebunit.webdriver;
+
+import org.openqa.selenium.JavascriptExecutor;
+
+import org.openqa.selenium.By;
+
+import org.openqa.selenium.WebElement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.jwebunit.api.IElement;
+
+import com.gargoylesoftware.htmlunit.html.DomNode;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
+
+/**
+ * Webdriver implementation of IElement wrapper.
+ *
+ * @author henryju
+ *
+ */
+public class WebDriverElementImpl implements IElement {
+
+ /**
+ * The wrapped element.
+ */
+ private WebElement element;
+
+ public WebDriverElementImpl(WebElement element) {
+ if (element == null)
+ throw new NullPointerException("Cannot create an IElement for a null element.");
+ this.element = element;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#attribute(java.lang.String)
+ */
+ public String getAttribute(String name) {
+ return element.getAttribute(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#name()
+ */
+ public String getName() {
+ return element.getTagName();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#getChildren()
+ */
+ public List<IElement> getChildren() {
+ List<IElement> children = new ArrayList<IElement>();
+ for (WebElement e : element.findElements(By.xpath("child::*"))) {
+ if (e != null)
+ children.add(new WebDriverElementImpl(e));
+ }
+ return children;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#getParent()
+ */
+ public IElement getParent() {
+ return new WebDriverElementImpl(element.findElement(By.xpath("//parent::*")));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#getTextContent()
+ */
+ public String getTextContent() {
+ return element.getText();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#getElement(java.lang.String)
+ */
+ public IElement getElement(String xpath) {
+ return new WebDriverElementImpl((WebElement) element.findElement(By.xpath(xpath)));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#getElements(java.lang.String)
+ */
+ public List<IElement> getElements(String xpath) {
+ List<IElement> elements = new ArrayList<IElement>();
+ for (WebElement o : element.findElements(By.xpath(xpath))) {
+ elements.add(new WebDriverElementImpl(o));
+ }
+ return elements;
+ }
+
+ public String toString() {
+ return "IElement[name=" + getName() + " wrapped=" + element + "]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#setAttribute(java.lang.String)
+ */
+ public void setAttribute(String string) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#setAttribute(java.lang.String, java.lang.String)
+ */
+ public void setAttribute(String string, String value) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.api.IElement#setTextContent(java.lang.String)
+ */
+ public void setTextContent(String value) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 37;
+ int result = 1;
+ result = prime * result + ((element == null) ? 0 : element.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final WebDriverElementImpl other = (WebDriverElementImpl) obj;
+ if (element == null) {
+ if (other.element != null)
+ return false;
+ }
+ else if (!element.equals(other.element))
+ return false;
+ return true;
+ }
+
+ /**
+ * Return the unwrapped Webdriver element that this IElement represents.
+ *
+ * @return the Webdriver element this IElement represents.
+ */
+ public WebElement getHtmlElement() {
+ return element;
+ }
+
+}
Property changes on: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverElementImpl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-09-23 14:52:27 UTC (rev 923)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebDriverTestingEngineImpl.java 2011-09-23 14:56:50 UTC (rev 924)
@@ -18,12 +18,16 @@
*/
package net.sourceforge.jwebunit.webdriver;
-import org.apache.regexp.RE;
-import org.apache.regexp.RESyntaxException;
+import org.apache.http.conn.BasicManagedEntity;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.util.NameValuePair;
-import com.gargoylesoftware.htmlunit.BrowserVersion;
+import java.io.ByteArrayInputStream;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.WebResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -33,6 +37,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import net.sourceforge.jwebunit.api.HttpHeader;
import net.sourceforge.jwebunit.api.IElement;
@@ -41,19 +46,39 @@
import net.sourceforge.jwebunit.exception.ExpectedJavascriptConfirmException;
import net.sourceforge.jwebunit.exception.ExpectedJavascriptPromptException;
import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
+import net.sourceforge.jwebunit.html.Cell;
+import net.sourceforge.jwebunit.html.Row;
import net.sourceforge.jwebunit.html.Table;
import net.sourceforge.jwebunit.javascript.JavascriptAlert;
import net.sourceforge.jwebunit.javascript.JavascriptConfirm;
import net.sourceforge.jwebunit.javascript.JavascriptPrompt;
import net.sourceforge.jwebunit.util.TestContext;
+import org.apache.commons.io.input.ProxyInputStream;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.HttpStatus;
+import org.apache.http.entity.HttpEntityWrapper;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.protocol.HttpContext;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+import org.browsermob.proxy.ProxyServer;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.NoSuchWindowException;
+import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
+import org.openqa.selenium.remote.CapabilityType;
+import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,47 +95,234 @@
* Logger for this class.
*/
private final Logger logger = LoggerFactory.getLogger(WebDriverTestingEngineImpl.class);
+ private ProxyServer proxyServer;
private WebDriver driver;
private TestContext testContext;
+ private static final int TRY_COUNT = 50;
+ private static final int DEFAULT_PORT = 8183;
+ private static final Random RANDOM = new Random();
+ private HttpResponse response;
+ private BasicBufferedHttpEntity entity;
// The xpath string that identifie the current form
// ie : @name='myForm'
private String formIdent;
+ private boolean throwExceptionOnScriptError = true;//TODO
+ private boolean ignoreFailingStatusCodes = false;
+ private Map<String, String> requestHeaders;
+ /**
+ * Is Javascript enabled.
+ */
+ private boolean jsEnabled = true;
public WebDriverTestingEngineImpl() {
}
public void beginAt(URL aInitialURL, TestContext aTestContext) throws TestingEngineResponseException {
this.setTestContext(aTestContext);
- driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3);
- ((HtmlUnitDriver) driver).setJavascriptEnabled(true);
+ // start the proxy
+ Proxy proxy = startBrowserMobProxy();
+ DesiredCapabilities capabilities = new DesiredCapabilities();
+ capabilities.setCapability(CapabilityType.PROXY, proxy);
+ capabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, jsEnabled);
+ capabilities.setBrowserName("htmlunit");
+ capabilities.setVersion("firefox");
+
+ driver = new FixedHtmlUnitDriver(capabilities);
//Reset form
formIdent = null;
+ // Deal with cookies
+ for (javax.servlet.http.Cookie c : aTestContext.getCookies()) {
+ //FIXME Hack for BrowserMob
+ String domain = c.getDomain();
+ if ("localhost".equals(domain)) {
+ domain = null;
+ }
+ if ("".equals(domain)) {
+ domain = null;
+ }
+ Date expiry = null;
+ if (c.getMaxAge() != -1) {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.SECOND, c.getMaxAge());
+ expiry = cal.getTime();
+ }
+ driver.manage().addCookie(
+ new org.openqa.selenium.Cookie(c
+ .getName(), c.getValue(), domain, c.getPath() != null ? c
+ .getPath() : "", expiry, c.getSecure()));
+ }
+ // Deal with custom request header
+ this.requestHeaders = aTestContext.getRequestHeaders();
+
gotoPage(aInitialURL);
}
+
+ private Proxy startBrowserMobProxy() {
+ for (int i = 1; i <= TRY_COUNT; i++) {
+ int port = getRandomPort();
+ proxyServer = new ProxyServer(port);
+ try {
+ proxyServer.start();
+ proxyServer.addResponseInterceptor(new HttpResponseInterceptor() {
+ public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
+ WebDriverTestingEngineImpl.this.response = response;
+ if (response instanceof BasicHttpResponse) {
+ BasicHttpResponse basicResponse = (BasicHttpResponse) response;
+ WebDriverTestingEngineImpl.this.entity = new BasicBufferedHttpEntity(response.getEntity());
+ basicResponse.setEntity(WebDriverTestingEngineImpl.this.entity);
+ }
+ else {
+ logger.error("Response is of type {}. Impossible to buffer content.", response.getClass().getSimpleName());
+ }
+ }
+ });
+ proxyServer.addRequestInterceptor(new HttpRequestInterceptor() {
+ public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
+ for (Map.Entry<String, String> requestHeader : requestHeaders.entrySet()) {
+ request.addHeader(requestHeader.getKey(), requestHeader.getValue());
+ }
+ }
+ });
+ return proxyServer.seleniumProxy();
+ }
+ catch (Exception e) {
+ if (i<TRY_COUNT) {
+ logger.error("Error while starting BrowserMob proxy. Retry...", e);
+ continue;
+ }
+ }
+ }
+ throw new RuntimeException("Unable to start BrowserMob proxy after " + TRY_COUNT + " retries");
+ }
+
+ private class BasicBufferedHttpEntity extends HttpEntityWrapper {
+
+ private BufferedInputStream bis;
+ public BasicBufferedHttpEntity(HttpEntity wrapped) {
+ super(wrapped);
+ }
+
+ @Override
+ public InputStream getContent() throws IOException {
+ if (bis == null) {
+ bis = new BufferedInputStream(super.getContent());
+ }
+ return bis;
+ }
+
+ public byte[] getBufferedContent() {
+ return bis.getBuffer();
+ }
+
+ }
+
+ private class BufferedInputStream extends ProxyInputStream {
+
+ private ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ public BufferedInputStream(InputStream proxy) {
+ super(proxy);
+ }
+
+
+ public byte[] getBuffer() {
+ return bos.toByteArray();
+ }
+
+ @Override
+ public int read() throws IOException {
+ int b = super.read();
+ if (b != -1) {
+ bos.write(b);
+ }
+ return b;
+ }
+
+ @Override
+ public int read(byte[] array) throws IOException {
+ int len = super.read(array);
+ if (len > 0) {
+ bos.write(array, 0, len);
+ }
+ return len;
+ }
+
+ @Override
+ public int read(byte[] array, int off, int len) throws IOException {
+ int len2 = super.read(array, off, len);
+ if (len2 > 0) {
+ bos.write(array, 0, len2);
+ }
+ return len2;
+ }
+
+ }
+
+ private static int getRandomPort() {
+ synchronized (RANDOM) {
+ return DEFAULT_PORT + RANDOM.nextInt(1000);
+ }
+ }
+
public void setTestContext(TestContext testContext) {
this.testContext = testContext;
}
public void closeBrowser() throws ExpectedJavascriptAlertException, ExpectedJavascriptConfirmException, ExpectedJavascriptPromptException {
formIdent = null;
- driver.close();
+ if (driver != null) {
+ driver.quit();
+ driver = null;
+ }
+ if (proxyServer != null) {
+ try {
+ proxyServer.stop();
+ proxyServer = null;
+ }
+ catch (Exception e) {
+ logger.error("Error while stopping proxy", e);
+ throw new RuntimeException("Error while stopping proxy", e);
+ }
+ }
}
public void gotoPage(URL url) throws TestingEngineResponseException {
formIdent = null;
- driver.get(url.toString());
+ //Big hack for browsermob
+ String urlStr = url.toString().replace("http://localhost", "http://127.0.0.1");
+ driver.get(urlStr);
+ throwFailingHttpStatusCodeExceptionIfNecessary(
+ response.getStatusLine().getStatusCode(), urlStr);
}
+
+ /**
+ * Copied from {@link WebClient#throwFailingHttpStatusCodeExceptionIfNecessary(WebResponse)}
+ *
+ * @param webResponse
+ */
+ private void throwFailingHttpStatusCodeExceptionIfNecessary(int statusCode, String url) {
+ final boolean successful = (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES)
+ || statusCode == HttpStatus.SC_USE_PROXY
+ || statusCode == HttpStatus.SC_NOT_MODIFIED;
+ if (!this.ignoreFailingStatusCodes && !successful) {
+ throw new TestingEngineResponseException(statusCode,
+ "unexpected status code [" + statusCode + "] at URL: [" + url + "]");
+ }
+ }
public void setScriptingEnabled(boolean value) {
- if (driver instanceof HtmlUnitDriver) {
+ // This variable is used to set Javascript before wc is instancied
+ jsEnabled = value;
+ if (driver != null && driver instanceof HtmlUnitDriver) {
((HtmlUnitDriver) driver).setJavascriptEnabled(value);
}
}
public void setThrowExceptionOnScriptError(boolean value) {
+ this.throwExceptionOnScriptError = true;
}
public List<javax.servlet.http.Cookie> getCookies() {
@@ -171,19 +383,21 @@
String current = driver.getWindowHandle();
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);
- if (driver.getTitle().equals(title)) {
+ if (title.equals(driver.getTitle())) {
return;
}
}
driver.switchTo().window(current);
+ throw new RuntimeException("No window found with title [" + title + "]");
}
public void gotoWindow(int windowID) {
- throw new UnsupportedOperationException("Not supported yet.");
+ Set<String> handles = driver.getWindowHandles();
+ driver.switchTo().window(handles.toArray(new String[handles.size()])[windowID]);
}
public void gotoRootWindow() {
- throw new UnsupportedOperationException("Not supported yet.");
+ driver.switchTo().defaultContent();
}
public int getWindowCount() {
@@ -192,11 +406,18 @@
public void closeWindow() {
formIdent = null;
- driver.close();
+ driver.close();//FIXME Issue 1466
}
public boolean hasFrame(String frameNameOrId) {
- throw new UnsupportedOperationException("Not supported yet.");
+ List<WebElement> frameset = driver.findElements(By.tagName("frame"));
+ for (WebElement frame : frameset) {
+ if (frameNameOrId.equals(frame.getAttribute("name"))
+ || frameNameOrId.equals(frame.getAttribute("id"))) {
+ return true;
+ }
+ }
+ return false;
}
public void gotoFrame(String frameNameOrId) {
@@ -209,7 +430,7 @@
public void setWorkingForm(String nameOrId, int index) {
if (nameOrId != null) {
- formIdent = "(@name='" + nameOrId + "' or @id='" + nameOrId + "')][position()="
+ formIdent = "(@name=" + escapeQuotes(nameOrId) + " or @id=" + escapeQuotes(nameOrId) + ")][position()="
+ (index + 1);
} else {
formIdent = null;
@@ -228,20 +449,20 @@
}
public boolean hasForm(String nameOrID) {
- return hasElementByXPath("//form[@name='" + nameOrID + "' or @id='" + nameOrID + "']");
+ return hasElementByXPath("//form[@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + "]");
}
public boolean hasFormParameterNamed(String paramName) {
- return hasElementByXPath(formSelector() + "//*[@name='" + paramName + "']");
+ return getWebElementByXPath("//*[@name=" + escapeQuotes(paramName) + "]", false, true) != null;
}
- private WebElement getWebElementByXPath(String xpathAfterForm, boolean onlyInCurrentForm) {
+ private WebElement getWebElementByXPath(String xpathAfterForm, boolean searchOnlyInCurrentForm, boolean overrideWorkingForm) {
//First try the current form
if (formIdent != null) {
try {
return driver.findElement(By.xpath("//form[" + formIdent + "]" + xpathAfterForm));
} catch (NoSuchElementException ex) {
- if (onlyInCurrentForm) {
+ if (searchOnlyInCurrentForm) {
return null;
}
}
@@ -252,7 +473,9 @@
for (WebElement f : forms) {
try {
WebElement e = driver.findElement(By.xpath("//form[position()=" + (index + 1) + "]" + xpathAfterForm));
- setWorkingForm(index);
+ if (overrideWorkingForm) {
+ setWorkingForm(index);
+ }
return e;
} catch (NoSuchElementException ex) {
index ++;
@@ -275,29 +498,40 @@
}
public String getTextFieldValue(String paramName) {
- WebElement e = getWebElementByXPath("//input[@type='text' and @name='" + paramName + "']", false);
- return e.getValue();
+ WebElement e = getTextField(paramName);
+ return e.getAttribute("value");
}
public String getHiddenFieldValue(String paramName) {
- WebElement e = getWebElementByXPath("//input[@type='hidden' and @name='" + paramName + "']", false);
- return e.getValue();
+ WebElement e = getWebElementByXPath("//input[@type='hidden' and @name=" + escapeQuotes(paramName) + "]", false, true);
+ return e.getAttribute("value");
}
public void setTextField(String inputName, String text) {
- WebElement e = getWebElementByXPath("//input[@type='text' and @name='" + inputName + "']", false);
+ WebElement e = getTextField(inputName);
+ e.clear();
+ e.sendKeys(text);
+ }
+
+ /**
+ * Look for any text field (input text, input password, textarea, file input).
+ */
+ private WebElement getTextField(String paramName) {
+ WebElement e = getWebElementByXPath("//input[@type='text' and @name=" + escapeQuotes(paramName) + "]", false, true);
if (e == null) {
- e = getWebElementByXPath("//textarea[@name='" + inputName + "']", false);
+ e = getWebElementByXPath("//textarea[@name=" + escapeQuotes(paramName) + "]", false, true);
}
if (e == null) {
- e = getWebElementByXPath("//input[@type='file' and @name='" + inputName + "']", false);
+ e = getWebElementByXPath("//input[@type='file' and @name=" + escapeQuotes(paramName) + "]", false, true);
}
- e.clear();
- e.sendKeys(text);
+ if (e == null) {
+ e = getWebElementByXPath("//input[@type='password' and @name=" + escapeQuotes(paramName) + "]", false, true);
+ }
+ return e;
}
public void setHiddenField(String inputName, String text) {
- WebElement e = getWebElementByXPath("//input[@type='hidden' and @name='" + inputName + "']", false);
+ WebElement e = getWebElementByXPath("//input[@type='hidden' and @name=" + escapeQuotes(inputName) + "]", false, true);
((JavascriptExecutor)driver).executeScript("arguments[0].value=" + escapeQuotes(text), e);
}
@@ -306,10 +540,10 @@
}
public String[] getSelectOptionValues(String selectName, int index) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + " and position()=" + (index + 1) + "]", true, true));
ArrayList<String> result = new ArrayList<String>();
for (WebElement opt : select.getOptions()) {
- result.add(opt.getValue());
+ result.add(opt.getAttribute("value"));
}
return result.toArray(new String[result.size()]);
}
@@ -319,23 +553,24 @@
}
private String[] getSelectedOptions(Select select) {
+ //FIXME http://code.google.com/p/selenium/issues/detail?id=2295
String[] result = new String[select.getAllSelectedOptions().size()];
int i = 0;
for (WebElement opt : select.getAllSelectedOptions()) {
- result[i++] = opt.getValue();
+ result[i++] = opt.getAttribute("value");
}
return result;
}
public String[] getSelectedOptions(String selectName, int index) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
return getSelectedOptions(select);
}
private String getSelectOptionValueForLabel(Select select, String label) {
for (WebElement opt : select.getOptions()) {
if (opt.getText().equals(label)) {
- return opt.getValue();
+ return opt.getAttribute("value");
}
}
throw new RuntimeException("Unable to find option " + label);
@@ -343,7 +578,7 @@
private String getSelectOptionLabelForValue(Select select, String value) {
for (WebElement opt : select.getOptions()) {
- if (opt.getValue().equals(value)) {
+ if (opt.getAttribute("value").equals(value)) {
return opt.getText();
}
}
@@ -351,22 +586,22 @@
}
public String getSelectOptionLabelForValue(String selectName, String optionValue) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "']", true));
+ Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "']", true, true));
return getSelectOptionLabelForValue(select, optionValue);
}
public String getSelectOptionLabelForValue(String selectName, int index, String optionValue) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
return getSelectOptionLabelForValue(select, optionValue);
}
public String getSelectOptionValueForLabel(String selectName, String optionLabel) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "']", true));
+ Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "']", true, true));
return getSelectOptionValueForLabel(select, optionLabel);
}
public String getSelectOptionValueForLabel(String selectName, int index, String optionLabel) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
return getSelectOptionValueForLabel(select, optionLabel);
}
@@ -375,13 +610,13 @@
}
public void selectOptions(String selectName, int index, String[] optionValues) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
if (!select.isMultiple() && optionValues.length > 1)
throw new RuntimeException("Multiselect not enabled");
for (String option : optionValues) {
boolean found = false;
for (WebElement opt : select.getOptions()) {
- if (opt.getValue().equals(option)) {
+ if (opt.getAttribute("value").equals(option)) {
select.selectByValue(option);
found = true;
break;
@@ -399,13 +634,13 @@
}
public void unselectOptions(String selectName, int index, String[] optionValues) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true, true));
if (!select.isMultiple() && optionValues.length > 1)
throw new RuntimeException("Multiselect not enabled");
for (String option : optionValues) {
boolean found = false;
for (WebElement opt : select.getOptions()) {
- if (opt.getValue().equals(option)) {
+ if (opt.getAttribute("value").equals(option)) {
select.deselectByValue(option);
found = true;
break;
@@ -427,7 +662,7 @@
}
public boolean hasSelectOption(String selectName, int index, String optionLabel) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + " and position()=" + (index + 1) + "]", true, true));
for (WebElement opt : select.getOptions()) {
if (opt.getText().equals(optionLabel)) {
return true;
@@ -437,9 +672,9 @@
}
public boolean hasSelectOptionValue(String selectName, int index, String optionValue) {
- Select select = new Select(getWebElementByXPath("//select[@name='" + selectName + "' and position()=" + (index + 1) + "]", true));
+ Select select = new Select(getWebElementByXPath("//select[@name=" + escapeQuotes(selectName) + " and position()=" + (index + 1) + "]", true, true));
for (WebElement opt : select.getOptions()) {
- if (opt.getValue().equals(optionValue)) {
+ if (opt.getAttribute("value").equals(optionValue)) {
return true;
}
}
@@ -447,125 +682,131 @@
}
public boolean isCheckboxSelected(String checkBoxName) {
- WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name='" + checkBoxName + "']", true);
+ WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + "]", true, true);
return e.isSelected();
}
public boolean isCheckboxSelected(String checkBoxName, String checkBoxValue) {
- WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name='" + checkBoxName + "' and @value='" + checkBoxValue + "']", true);
+ WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + " and @value=" + escapeQuotes(checkBoxValue) + "]", true, true);
return e.isSelected();
}
public void checkCheckbox(String checkBoxName) {
- WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name='" + checkBoxName + "']", true);
+ WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + "]", true, true);
if (!e.isSelected()) {
- e.toggle();
+ e.click();
}
}
public void checkCheckbox(String checkBoxName, String checkBoxValue) {
- WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name='" + checkBoxName + "' and @value='" + checkBoxValue + "']", true);
+ WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + " and @value=" + escapeQuotes(checkBoxValue) + "]", true, true);
if (!e.isSelected()) {
- e.toggle();
+ e.click();
}
}
public void uncheckCheckbox(String checkBoxName) {
- WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name='" + checkBoxName + "']", true);
+ WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + "]", true, true);
if (e.isSelected()) {
- e.toggle();
+ e.click();
}
}
public void uncheckCheckbox(String checkBoxName, String value) {
- WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name='" + checkBoxName + "' and @value='" + value + "']", true);
+ WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + " and @value=" + escapeQuotes(value) + "]", true, true);
if (e.isSelected()) {
- e.toggle();
+ e.click();
}
}
public void clickRadioOption(String radioGroup, String radioOptionValue) {
- WebElement e = getWebElementByXPath("//input[@type='radio' and @name='" + radioGroup + "' and @value='" + radioOptionValue + "']", false);
+ WebElement e = getWebElementByXPath("//input[@type='radio' and @name=" + escapeQuotes(radioGroup) + " and @value=" + escapeQuotes(radioOptionValue) + "]", false, true);
e.click();
}
public boolean hasRadioOption(String radioGroup, String radioOptionValue) {
- WebElement e = getWebElementByXPath("//input[@type='radio' and @name='" + radioGroup + "' and @value='" + radioOptionValue + "']", false);
+ WebElement e = getWebElementByXPath("//input[@type='radio' and @name=" + escapeQuotes(radioGroup) + " and @value=" + escapeQuotes(radioOptionValue) + "]", false, true);
return e != null;
}
public String getSelectedRadio(String radioGroup) {
- List<WebElement> radios = getWebElementsByXPath("/input[@type='radio' and @name='" + radioGroup + "']");
+ List<WebElement> radios = getWebElementsByXPath("/input[@type='radio' and @name=" + escapeQuotes(radioGroup) + "]");
for (WebElement r : radios) {
if (r.isSelected()) {
- return r.getValue();
+ return r.getAttribute("value");
}
}
return null;
}
public boolean hasSubmitButton() {
- return (getWebElementByXPath("//input[@type='submit' or @type='image']", true) != null) || (getWebElementByXPath("//button[@type='submit']", false) != null);
+ return (getWebElementByXPath("//input[@type='submit' or @type='image']", true, true) != null) || (getWebElementByXPath("//button[@type='submit']", false, true) != null);
}
public boolean hasSubmitButton(String nameOrID) {
- return (getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name='" + nameOrID + "' or @id='" + nameOrID + "')]", true) != null)
- || (getWebElementByXPath("//button[@type='submit' and (@name='" + nameOrID + "' or @id='" + nameOrID + "')]", true) != null);
+ return (getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name=" + escapeQuotes(nameOrID) + " or @id=" + nameOrID + ")]", true, true) != null)
+ || (getWebElementByXPath("//button[@type='submit' and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ")]", true, true) != null);
}
public boolean hasSubmitButton(String nameOrID, String value) {
- return (getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name='" + nameOrID + "' or @id='" + nameOrID + "') and @value='" + value + "']", true) != null)
- || (getWebElementByXPath("//button[@type='submit' and (@name='" + nameOrID + "' or @id='" + nameOrID + "') and @value='" + value + "']", true) != null);
+ return (getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ") and @value=" + escapeQuotes(value) + "]", true, true) != null)
+ || (getWebElementByXPath("//button[@type='submit' and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ") and @value=" + escapeQuotes(value) + "]", true, true) != null);
}
public void submit() {
- WebElement e = getWebElementByXPath("//input[@type='submit' or @type='image']", true);
+ WebElement e = getWebElementByXPath("//input[@type='submit' or @type='image']", true, true);
if (e == null) {
- e = getWebElementByXPath("//button[@type='submit']", true);
+ e = getWebElementByXPath("//button[@type='submit']", true, true);
}
e.submit();
+ throwFailingHttpStatusCodeExceptionIfNecessary(
+ response.getStatusLine().getStatusCode(), driver.getCurrentUrl());
}
public void submit(String nameOrID) {
- WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name='" + nameOrID + "' or @id='" + nameOrID + "')]", true);
+ WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ")]", true, true);
if (e == null) {
- e = getWebElementByXPath("//button[@type='submit' and (@name='" + nameOrID + "' or @id='" + nameOrID + "')]", true);
+ e = getWebElementByXPath("//button[@type='submit' and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ")]", true, true);
}
e.submit();
+ throwFailingHttpStatusCodeExceptionIfNecessary(
+ response.getStatusLine().getStatusCode(), driver.getCurrentUrl());
}
public void submit(String buttonName, String buttonValue) {
- WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name='" + buttonName + "' or @id='" + buttonName + "') and @value='" + buttonValue + "']", true);
+ WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='image') and (@name=" + escapeQuotes(buttonName) + " or @id=" + escapeQuotes(buttonName) + ") and @value=" + escapeQuotes(buttonValue) + "]", true, true);
if (e == null) {
- e = getWebElementByXPath("//button[@type='submit' and (@name='" + buttonName + "' or @id='" + buttonName + "') and @value='" + buttonValue + "']", true);
+ e = getWebElementByXPath("//button[@type='submit' and (@name=" + escapeQuotes(buttonName) + " or @id=" + escapeQuotes(buttonName) + ") and @value=" + escapeQuotes(buttonValue) + "]", true, true);
}
e.submit();
+ throwFailingHttpStatusCodeExceptionIfNecessary(
+ response.getStatusLine().getStatusCode(), driver.getCurrentUrl());
}
public boolean hasResetButton() {
- return getWebElementByXPath("//input[@type='reset']", false) != null;
+ return getWebElementByXPath("//input[@type='reset']", false, true) != null;
}
public boolean hasResetButton(String nameOrID) {
- return getWebElementByXPath("//input[@type='reset' and (@name='" + nameOrID + "' or @id='" + nameOrID + "')]", true) != null;
+ return getWebElementByXPath("//input[@type='reset' and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ")]", true, true) != null;
}
public void reset() {
- getWebElementByXPath("//input[@type='reset']", true).click();;
+ getWebElementByXPath("//input[@type='reset']", true, true).click();;
}
private WebElement getButton(String nameOrID) {
- WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='image' or @type='reset' or @type='button') and (@name='" + nameOrID + "' or @id='" + nameOrID + "')]", false);
+ WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='image' or @type='reset' or @type='button') and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ")]", false, true);
if (e == null) {
- e = getWebElementByXPath("//button[@type='submit' and (@name='" + nameOrID + "' or @id='" + nameOrID + "')]", false);
+ e = getWebElementByXPath("//button[@type='submit' and (@name=" + escapeQuotes(nameOrID) + " or @id=" + escapeQuotes(nameOrID) + ")]", false, true);
}
return e;
}
private WebElement getButtonWithText(String text) {
- WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='reset' or @type='button') and contains(@value," + escapeQuotes(text) + ")]", false);
+ WebElement e = getWebElementByXPath("//input[(@type='submit' or @type='reset' or @type='button') and contains(@value," + escapeQuotes(text) + ")]", false, true);
if (e == null) {
- e = getWebElementByXPath("//button[contains(.," + escapeQuotes(text) + ")]", false);
+ e = getWebElementByXPath("//button[contains(.," + escapeQuotes(text) + ")]", false, true);
}
return e;
}
@@ -595,11 +836,32 @@
}
public String getPageText() {
- return driver.findElement(By.xpath("//body")).getText();
+ try {
+ return driver.findElement(By.xpath("//body")).getText();
+ } catch (Exception e) {
+ //Maybe this is not HTML
+ return driver.getPageSource();
+ }
}
public String getPageSource() {
- return driver.getPageSource();
+ String encoding = "ISO-8859-1";
+ if (response.getEntity().getContentEncoding() != null) {
+ encoding = response.getEntity().getContentEncoding().getValue();
+ }
+
+ if (response.getEntity() instanceof BasicBufferedHttpEntity) {
+ try {
+ return new String(((BasicBufferedHttpEntity) response.getEntity()).getBufferedContent(),
+ encoding);
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ else {
+ return driver.getPageSource();
+ }
}
public String getPageTitle() {
@@ -611,6 +873,9 @@
}
public InputStream getInputStream() {
+ if (entity != null) {
+ return new ByteArrayInputStream(entity.getBufferedContent());
+ }
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -619,12 +884,55 @@
}
public boolean hasTable(String tableSummaryNameOrId) {
- throw new UnsupportedOperationException("Not supported yet.");
+ return getHtmlTable(tableSummaryNameOrId) != null;
}
public Table getTable(String tableSummaryNameOrId) {
- throw new UnsupportedOperationException("Not supported yet.");
+ WebElement table = getHtmlTable(tableSummaryNameOrId);
+ Table result = new Table();
+ List<WebElement> trs = table.findElements(By.xpath("tr | tbody/tr"));
+ for (int i = 0; i < trs.size(); i++) {
+ Row newRow = new Row();
+ WebElement tr = trs.get(i);
+ List<WebElement> tds = tr.findElements(By.xpath("td | th"));
+ for (WebElement td : tds) {
+ int colspan;
+ try {
+ colspan = Integer.valueOf(td.getAttribute("colspan"));
+ }
+ catch (NumberFormatException e) {
+ colspan = 1;
+ }
+ int rowspan;
+ try {
+ rowspan = Integer.valueOf(td.getAttribute("rowspan"));
+ }
+ catch (NumberFormatException e) {
+ rowspan = 1;
+ }
+ newRow.appendCell(new Cell(td.getText(),
+ colspan,
+ rowspan));
+ }
+ result.appendRow(newRow);
+ }
+ return result;
}
+
+ /**
+ * Return the Webdriver WebElement object representing a specified table in the current response. Null is returned if a
+ * parsing exception occurs looking for the table or no table with the id or summary could be found.
+ *
+ * @param tableSummaryOrId summary or id of the table to return.
+ */
+ private WebElement getHtmlTable(String tableSummaryOrId) {
+ try {
+ return driver.findElement(By.xpath("(//table[@id="
+ + escapeQuotes(tableSummaryOrId) + " or @summary=" + escapeQuotes(tableSummaryOrId) + "])"));
+ } catch (NoSuchElementException e) {
+ return null;
+ }
+ }
private WebElement getLinkWithImage(String filename, int index) {
try {
@@ -679,11 +987,21 @@
}
public void clickLinkWithText(String linkText, int index) {
- throw new UnsupportedOperationException("Not supported yet.");
+ WebElement link = getLinkWithText(linkText, index);
+ if (link == null) {
+ throw new RuntimeException("No Link found for \"" + linkText
+ + "\" with index " + index);
+ }
+ link.click();
}
public void clickLinkWithExactText(String linkText, int index) {
- throw new UnsupportedOperationException("Not supported yet.");
+ WebElement link = getLinkWithExactText(linkText, index);
+ if (link == null) {
+ throw new RuntimeException("No Link found for \"" + linkText
+ + "\" with index " + index);
+ }
+ link.click();
}
public void clickLink(String anID) {
@@ -691,9 +1009,14 @@
}
public void clickLinkWithImage(String imageFileName, int index) {
- throw new UnsupportedOperationException("Not supported yet.");
+ WebElement link = getLinkWithImage(imageFileName, index);
+ if (link == null) {
+ throw new RuntimeException("No Link found with filename \""
+ + imageFileName + "\" and index " + index);
+ }
+ link.click();
}
-
+
public boolean hasElement(String anID) {
try {
driver.findElement(By.id(anID));
@@ -759,7 +1082,9 @@
} catch (RESyntaxException e) {
throw new RuntimeException(e);
}
- } public void setExpectedJavaScriptAlert(JavascriptAlert[] alerts) throws ExpectedJavascriptAlertException {
+ }
+
+ public void setExpectedJavaScriptAlert(JavascriptAlert[] alerts) throws ExpectedJavascriptAlertException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -772,31 +1097,50 @@
}
public IElement getElementByXPath(String xpath) {
- throw new UnsupportedOperationException("Not supported yet.");
+ try {
+ return new WebDriverElementImpl(driver.findElement(By.xpath(xpath)));
+ }
+ catch (NoSuchElementException e) {
+ return null;
+ }
}
public IElement getElementByID(String id) {
- throw new UnsupportedOperationException("Not supported yet.");
+ try {
+ return new WebDriverElementImpl(driver.findElement(By.id(id)));
+ }
+ catch (NoSuchElementException e) {
+ return null;
+ }
}
public List<IElement> getElementsByXPath(String xpath) {
- throw new UnsupportedOperationException("Not supported yet.");
+ List<IElement> result = new ArrayList<IElement>();
+ List<WebElement> elements = driver.findElements(By.xpath(xpath));
+ for (WebElement child : elements) {
+ result.add(new WebDriverElementImpl(child));
+ }
+ return result;
}
public int getServerResponseCode() {
- throw new UnsupportedOperationException("Not supported yet.");
+ return response.getStatusLine().getStatusCode();
}
public String getHeader(String name) {
- throw new UnsupportedOperationException("Not supported yet.");
+ return response.getHeaders(name).length>0?response.getHeaders(name)[0].getValue():null;
}
public Map<String, String> getAllHeaders() {
- throw new UnsupportedOperationException("Not supported yet.");
+ Map<String, String> map = new java.util.HashMap<String, String>();
+ for (Header header : response.getAllHeaders()) {
+ map.put(header.getName(), header.getValue());
+ }
+ return map;
}
public void setIgnoreFailingStatusCodes(boolean ignore) {
- throw new UnsupportedOperationException("Not supported yet.");
+ this.ignoreFailingStatusCodes = ignore;
}
public List<String> getComments() {
@@ -808,8 +1152,11 @@
}
public List<HttpHeader> getResponseHeaders() {
- // TODO Auto-generated method stub
- return null;
+ List<HttpHeader> result = new LinkedList<HttpHeader>();
+ for (Header header : response.getAllHeaders()) {
+ result.add(new HttpHeader(header.getName(), header.getValue()));
+ }
+ return result;
}
/**
Deleted: trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebdriverElementImpl.java
===================================================================
--- trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebdriverElementImpl.java 2011-09-23 14:52:27 UTC (rev 923)
+++ trunk/jwebunit-webdriver-plugin/src/main/java/net/sourceforge/jwebunit/webdriver/WebdriverElementImpl.java 2011-09-23 14:56:50 UTC (rev 924)
@@ -1,198 +0,0 @@
-/**
- * Copyright (c) 2010, JWebUnit team.
- *
- * This file is part of JWebUnit.
- *
- * JWebUnit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * JWebUnit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- *
- */
-package net.sourceforge.jwebunit.webdriver;
-
-import org.openqa.selenium.JavascriptExecutor;
-
-import org.openqa.selenium.By;
-
-import org.openqa.selenium.WebElement;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sourceforge.jwebunit.api.IElement;
-
-import com.gargoylesoftware.htmlunit.html.DomNode;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlInput;
-import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
-
-/**
- * Webdriver implementation of IElement wrapper.
- *
- * @author henryju
- *
- */
-public class WebdriverElementImpl implements IElement {
-
- /**
- * The wrapped element.
- */
- private WebElement element;
-
- public WebdriverElementImpl(WebElement element) {
- if (element == null)
- throw new NullPointerException("Cannot create an IElement for a null element.");
- this.element = element;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.api.IElement#attribute(java.lang.String)
- */
- public String getAttribute(String name) {
- return element.getAttribute(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.api.IElement#name()
- */
- public String getName() {
- return element.getTagName();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.api.IElement#getChildren()
- */
- public List<IElement> getChildren() {
- List<IElement> children = new ArrayList<IElement>();
- for (WebElement e : element.findElements(By.xpath("/"))) {
- if (e != null)
- children.add(new WebdriverElementImpl(e));
- }
- return children;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.api.IElement#getParent()
- */
- public IElement getParent() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.api.IElement#getTextContent()
- */
- public String getTextContent() {
- return element.getText();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.api.IElement#getElement(java.lang.String)
- */
- public IElement getElement(String xpath) {
- return new WebdriverElementImpl((WebElement) element.findElement(By.xpath(xpath)));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.api.IElement#getElements(java.lang.String)
- */
- public List<IElement> getElements(String xpath) {
- List<IElement> elements = new ArrayList<IElement>();
- for (WebElement o : element.findElements(By.xpath(xpath))) {
- elements.add(new WebdriverElementImpl(o));
- }
- return elemen...
[truncated message content] |
|
From: <he...@us...> - 2011-09-23 14:52:34
|
Revision: 923
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=923&view=rev
Author: henryju
Date: 2011-09-23 14:52:27 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
It is now possible to run each test individually (in Eclipse, I first have to run the full test suite, but after I can select which individual test or package I want re-run).
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2011-09-23 14:50:45 UTC (rev 922)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JWebUnitAPITestCase.java 2011-09-23 14:52:27 UTC (rev 923)
@@ -18,6 +18,8 @@
*/
package net.sourceforge.jwebunit.tests;
+import net.sourceforge.jwebunit.tests.util.JettySetup;
+
import java.lang.reflect.InvocationTargetException;
import org.junit.After;
@@ -35,7 +37,7 @@
*
* @author Nicholas Neuberger
*/
-public abstract class JWebUnitAPITestCase {
+public abstract class JWebUnitAPITestCase extends JettySetup {
protected static final Object[] NOARGS = new Object[0];
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java 2011-09-23 14:50:45 UTC (rev 922)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java 2011-09-23 14:52:27 UTC (rev 923)
@@ -45,6 +45,8 @@
* The Jetty server we are going to use as test server.
*/
private static Server jettyServer = null;
+
+ private static boolean started = false;
/**
@@ -54,62 +56,61 @@
* @see junit.extensions.TestSetup#setUp()
*/
@BeforeClass
- public static void setUp() throws Exception {
- try {
- jettyServer = new Server();
- SelectChannelConnector connector = new SelectChannelConnector();
- connector.setPort(JWebUnitAPITestCase.JETTY_PORT);
- connector.setAcceptors(5);
- connector.setPort(JWebUnitAPITestCase.JETTY_PORT);
- jettyServer.setConnectors(new Connector[] { connector });
-
- WebAppContext wah = new WebAppContext();
-
- // Handle files encoded in UTF-8
- MimeTypes mimeTypes = new MimeTypes();
- mimeTypes.addMimeMapping("html_utf-8", "text/html; charset=UTF-8");
- mimeTypes.addMimeMapping("txt", "text/plain");
- mimeTypes.addMimeMapping("bin", "application/octet-stream");
- wah.setMimeTypes(mimeTypes);
-
-
- HandlerCollection handlers= new HandlerCollection();
- handlers.setHandlers(new Handler[]{wah, new DefaultHandler()});
-
- jettyServer.setHandler(wah);
- HashLoginService myrealm = new HashLoginService("MyRealm");
- URL config = JettySetup.class.getResource("/jetty-users.properties");
- myrealm.setConfig(config.toString());
- jettyServer.addBean(myrealm);
-
- wah.setContextPath(JWebUnitAPITestCase.JETTY_URL);
-
- URL url = JettySetup.class.getResource("/testcases/");
- wah.setWar(url.toString());
-
- jettyServer.start();
-
- } catch (Exception e) {
- e.printStackTrace();
- fail("Could not start the Jetty server: " + e);
- }
+ public static void startup() throws Exception {
+ if (!started) {
+ try {
+ jettyServer = new Server();
+ SelectChannelConnector connector = new SelectChannelConnector();
+ connector.setPort(JWebUnitAPITestCase.JETTY_PORT);
+ connector.setAcceptors(5);
+ connector.setPort(JWebUnitAPITestCase.JETTY_PORT);
+ jettyServer.setConnectors(new Connector[] { connector });
+
+ WebAppContext wah = new WebAppContext();
+
+ // Handle files encoded in UTF-8
+ MimeTypes mimeTypes = new MimeTypes();
+ mimeTypes.addMimeMapping("html_utf-8", "text/html; charset=UTF-8");
+ mimeTypes.addMimeMapping("txt", "text/plain");
+ mimeTypes.addMimeMapping("bin", "application/octet-stream");
+ wah.setMimeTypes(mimeTypes);
+
+
+ HandlerCollection handlers= new HandlerCollection();
+ handlers.setHandlers(new Handler[]{wah, new DefaultHandler()});
+
+ jettyServer.setHandler(wah);
+ HashLoginService myrealm = new HashLoginService("MyRealm");
+ URL config = JettySetup.class.getResource("/jetty-users.properties");
+ myrealm.setConfig(config.toString());
+ jettyServer.addBean(myrealm);
+
+ wah.setContextPath(JWebUnitAPITestCase.JETTY_URL);
+
+ URL url = JettySetup.class.getResource("/testcases/");
+ wah.setWar(url.toString());
+
+ jettyServer.start();
+
+ started = true;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Could not start the Jetty server: " + e);
+ }
+ }
}
-
- /**
- * Stops the Jetty server.
- *
- * @see junit.extensions.TestSetup#tearDown()
- */
- @AfterClass
- public static void tearDown() throws Exception {
- try {
- jettyServer.stop();
- } catch (InterruptedException e) {
- e.printStackTrace();
- fail("Jetty server was interrupted: " + e);
- } catch (Exception e) {
- e.printStackTrace();
- fail("Could not stop the Jetty server: " + e);
- }
- }
+
+ protected static void shutdown() throws Exception {
+ try {
+ jettyServer.stop();
+ started = false;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ fail("Jetty server was interrupted: " + e);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Could not stop the Jetty server: " + e);
+ }
+ }
}
Modified: trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java 2011-09-23 14:50:45 UTC (rev 922)
+++ trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java 2011-09-23 14:52:27 UTC (rev 923)
@@ -19,6 +19,8 @@
package net.sourceforge.jwebunit.htmlunit;
+import org.junit.AfterClass;
+
import net.sourceforge.jwebunit.tests.ButtonAssertionsTest;
import net.sourceforge.jwebunit.tests.CharsetTest;
import net.sourceforge.jwebunit.tests.CustomTesterTest;
@@ -85,5 +87,10 @@
ConcurrentJWebUnitTest.class
})
public class JWebUnitTest extends JettySetup {
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ shutdown();
+ }
}
Modified: trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java 2011-09-23 14:50:45 UTC (rev 922)
+++ trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/RefreshHandlerTest.java 2011-09-23 14:52:27 UTC (rev 923)
@@ -18,21 +18,20 @@
*/
package net.sourceforge.jwebunit.htmlunit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import net.sourceforge.jwebunit.tests.JWebUnitAPITestCase;
-import net.sourceforge.jwebunit.tests.util.JettySetup;
-import net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl;
import com.gargoylesoftware.htmlunit.ThreadedRefreshHandler;
import com.gargoylesoftware.htmlunit.WaitingRefreshHandler;
+import net.sourceforge.jwebunit.tests.JWebUnitAPITestCase;
+import org.junit.Test;
-import static net.sourceforge.jwebunit.junit.JWebUnit.*;
-import static org.junit.Assert.*;
+import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
+import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
+import static net.sourceforge.jwebunit.junit.JWebUnit.getTestingEngine;
+import static net.sourceforge.jwebunit.junit.JWebUnit.setBaseUrl;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
- * Unit test to validate JWEbUnit's HtmlUnit plugin will now allow for custom
+ * Unit test to validate JWebUnit's HtmlUnit plugin will now allow for custom
* RefreshHandler to be passed in prior to initialization, as well as changed on
* the fly.
*
@@ -40,16 +39,6 @@
* @author Jason McSwain
*/
public class RefreshHandlerTest extends JWebUnitAPITestCase {
-
- @BeforeClass
- public static void startJetty() throws Exception {
- JettySetup.setUp();
- }
-
- @AfterClass
- public static void stopJetty() throws Exception {
- JettySetup.tearDown();
- }
@Test
public void testDefaultRefreshHandler() throws Exception {
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 2011-09-23 14:50:45 UTC (rev 922)
+++ trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java 2011-09-23 14:52:27 UTC (rev 923)
@@ -18,6 +18,8 @@
*/
package net.sourceforge.jwebunit.selenium;
+import org.junit.AfterClass;
+
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -63,4 +65,8 @@
})
public class JWebUnitTest extends JettySetup {
+ @AfterClass
+ public static void tearDown() throws Exception {
+ shutdown();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 14:50:51
|
Revision: 922
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=922&view=rev
Author: henryju
Date: 2011-09-23 14:50:45 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Fix a test that was forgetting to close browser.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptEventsTest.java
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptEventsTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptEventsTest.java 2011-09-23 14:46:55 UTC (rev 921)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JavaScriptEventsTest.java 2011-09-23 14:50:45 UTC (rev 922)
@@ -81,19 +81,22 @@
assertTextPresent("Here is the text we expect");
}
- @Test public void testLinkAssertsWorkJavascriptDisabled() {
+ @Test
+ public void testLinkAssertsWorkJavascriptDisabled() {
setScriptingEnabled(false);
beginAt("index.html");
clickLink("linkNext");
assertTitleEquals("Startpage");
assertTextNotPresent("Here is the text we expect");
+ closeBrowser();
beginAt("index.html");
clickButton("next");
assertTitleEquals("Startpage");
assertTextNotPresent("Here is the text we expect");
+ closeBrowser();
+
setScriptingEnabled(true);
-
// and test that javascript is enabled for the next begin
beginAt("index.html");
clickLink("linkNext");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 14:47:01
|
Revision: 921
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=921&view=rev
Author: henryju
Date: 2011-09-23 14:46:55 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Cleanup of pom dependencies. Add WebDriverTestingEngine in the list of available engines.
Modified Paths:
--------------
trunk/jwebunit-core/pom.xml
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java
trunk/jwebunit-htmlunit-plugin/pom.xml
trunk/jwebunit-selenium-plugin/pom.xml
trunk/jwebunit-webdriver-plugin/pom.xml
trunk/pom.xml
Property Changed:
----------------
trunk/jwebunit-webdriver-plugin/
Modified: trunk/jwebunit-core/pom.xml
===================================================================
--- trunk/jwebunit-core/pom.xml 2011-09-23 14:44:03 UTC (rev 920)
+++ trunk/jwebunit-core/pom.xml 2011-09-23 14:46:55 UTC (rev 921)
@@ -24,10 +24,12 @@
<dependency>
<groupId>regexp</groupId>
<artifactId>regexp</artifactId>
+ <version>1.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
+ <version>2.5</version>
</dependency>
</dependencies>
<properties>
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java 2011-09-23 14:44:03 UTC (rev 920)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/util/TestingEngineRegistry.java 2011-09-23 14:46:55 UTC (rev 921)
@@ -40,6 +40,11 @@
*/
public final static String TESTING_ENGINE_SELENIUM = "TestingEngineSelenium";
+ /**
+ * Key of HtmlUnit testing engine.
+ */
+ public final static String TESTING_ENGINE_WEBDRIVER = "TestingEngineWebdriver";
+
private static Hashtable<String,Class<?>> testingEngineMap = new Hashtable<String,Class<?>>();
static {
@@ -57,6 +62,13 @@
} catch (ClassNotFoundException e) {
// Selenium Testing Engine is not present in the classpath. Nothing to do.
}
+ cp = "net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl";
+ // Try to load Webdriver Testing Engine to check if it is present.
+ try {
+ addTestingEngine(TESTING_ENGINE_WEBDRIVER, cp);
+ } catch (ClassNotFoundException e) {
+ // Webdriver Testing Engine is not present in the classpath. Nothing to do.
+ }
}
/**
Modified: trunk/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/pom.xml 2011-09-23 14:44:03 UTC (rev 920)
+++ trunk/jwebunit-htmlunit-plugin/pom.xml 2011-09-23 14:46:55 UTC (rev 921)
@@ -23,6 +23,7 @@
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
+ <version>2.9</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
@@ -56,6 +57,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
+ <version>2.5</version>
</dependency>
</dependencies>
<properties>
Modified: trunk/jwebunit-selenium-plugin/pom.xml
===================================================================
--- trunk/jwebunit-selenium-plugin/pom.xml 2011-09-23 14:44:03 UTC (rev 920)
+++ trunk/jwebunit-selenium-plugin/pom.xml 2011-09-23 14:46:55 UTC (rev 921)
@@ -55,6 +55,7 @@
<dependency>
<groupId>org.seleniumhq.selenium.client-drivers</groupId>
<artifactId>selenium-java-client-driver</artifactId>
+ <version>1.0.2</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
@@ -78,6 +79,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
+ <version>2.5</version>
</dependency>
</dependencies>
<properties>
Property changes on: trunk/jwebunit-webdriver-plugin
___________________________________________________________________
Modified: svn:ignore
- target
+ target
.project
.classpath
.settings
Modified: trunk/jwebunit-webdriver-plugin/pom.xml
===================================================================
--- trunk/jwebunit-webdriver-plugin/pom.xml 2011-09-23 14:44:03 UTC (rev 920)
+++ trunk/jwebunit-webdriver-plugin/pom.xml 2011-09-23 14:46:55 UTC (rev 921)
@@ -1,8 +1,9 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.0-SNAPSHOT</version>
+ <version>3.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -30,13 +31,19 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
- <version>2.0b2</version>
- </dependency>
+ <version>2.6.0</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
- <version>2.0b2</version>
- </dependency>
+ <version>2.6.0</version>
+ </dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
@@ -59,7 +66,27 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
+ <version>2.5</version>
</dependency>
+ <dependency>
+ <groupId>biz.neustar</groupId>
+ <artifactId>browsermob-proxy</artifactId>
+ <version>2.0-beta-3</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>org.apache.commons</artifactId>
+ <groupId>commons-io</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
</dependencies>
<properties>
<topDirectoryLocation>..</topDirectoryLocation>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-09-23 14:44:03 UTC (rev 920)
+++ trunk/pom.xml 2011-09-23 14:46:55 UTC (rev 921)
@@ -25,6 +25,7 @@
<module>jwebunit-commons-tests</module>
<module>jwebunit-htmlunit-plugin</module>
<module>jwebunit-selenium-plugin</module>
+ <module>jwebunit-webdriver-plugin</module>
</modules>
<mailingLists>
<mailingList>
@@ -395,36 +396,6 @@
<version>7.3.1.v20110307</version>
</dependency>
<dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2.2</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit</artifactId>
- <version>2.9</version>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium.client-drivers</groupId>
- <artifactId>selenium-java-client-driver</artifactId>
- <version>1.0.2</version>
- </dependency>
- <dependency>
- <groupId>regexp</groupId>
- <artifactId>regexp</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 14:44:09
|
Revision: 920
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=920&view=rev
Author: henryju
Date: 2011-09-23 14:44:03 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
HTMLUnitTestingEngine#getPageText() was updated to only return text that is inside <body> element. Consequently some JUnit tests needed update.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java 2011-09-23 14:33:49 UTC (rev 919)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java 2011-09-23 14:44:03 UTC (rev 920)
@@ -51,16 +51,18 @@
assertPassFail("assertWindowPresent", new Object[]{"ChildPage1"}, new Object[]{"NoSuchChild"});
}
- @Test public void testGotoWindow() {
+ @Test
+ public void testGotoWindow() {
gotoRootAndOpenChild("ChildPage1");
gotoWindow("ChildPage1");
- assertTextPresent("child 1");
+ assertTextPresent("Child Page 1");
}
- @Test public void testGotoWindowByTitle() {
+ @Test
+ public void testGotoWindowByTitle() {
gotoRootAndOpenChild("ChildPage2");
gotoWindowByTitle("Child Page 2");
- assertTextPresent("child 2");
+ assertTextPresent("This is child 2");
}
@Test public void testAssertWindowWithTitle() throws Throwable {
@@ -68,12 +70,13 @@
assertPassFail("assertWindowPresentWithTitle", new Object[]{"Child Page 2"}, new Object[]{"NoSuchTitle"});
}
- @Test public void testCloseWindow() {
+ @Test
+ public void testCloseWindow() {
beginAt("RootPage.html");
assertTitleEquals("This is the Root");
clickLink("ChildPage1");
gotoWindow("ChildPage1");
- assertTextPresent("child 1");
+ assertTextPresent("Child Page 1");
closeWindow();
assertWindowCountEquals(1);
assertTitleEquals("This is the Root");
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2011-09-23 14:33:49 UTC (rev 919)
+++ trunk/src/changes/changes.xml 2011-09-23 14:44:03 UTC (rev 920)
@@ -32,6 +32,9 @@
<body>
<release version="3.1" date="UNKNOW" description="Cleanup for Webdriver integration">
<action type="update" dev="henryju">
+ getPageText() (and all related assertXX methods) now only deals with what is inside <body> element. Previously it was also returning page title for example.
+ </action>
+ <action type="update" dev="henryju">
gotoRootWindow() now goes to the root "frame" in a multi-frame window. Previously it was only by chance.
</action>
<action type="update" dev="henryju">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 14:33:55
|
Revision: 919
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=919&view=rev
Author: henryju
Date: 2011-09-23 14:33:49 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Some minor fixes to HtmlUnit discovered while coding WebDriver testing engine.
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2011-09-23 14:19:55 UTC (rev 918)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2011-09-23 14:33:49 UTC (rev 919)
@@ -18,6 +18,8 @@
*/
package net.sourceforge.jwebunit.htmlunit;
+import com.gargoylesoftware.htmlunit.TopLevelWindow;
+
import net.sourceforge.jwebunit.api.HttpHeader;
import org.apache.http.auth.AuthScope;
@@ -350,6 +352,9 @@
if (window != null) {
setMainWindow(window);
}
+ else {
+ throw new RuntimeException("No window found with title [" + title + "]");
+ }
}
/**
@@ -357,7 +362,7 @@
*/
public void closeWindow() {
if (win != null) {
- wc.deregisterWebWindow(win);
+ ((TopLevelWindow) win.getTopWindow()).close();
win = wc.getCurrentWindow();
form = null;
}
@@ -712,7 +717,7 @@
public String getPageText() {
Page page = win.getEnclosedPage();
if (page instanceof HtmlPage) {
- return ((HtmlPage) page).asText();
+ return ((HtmlPage) page).getBody().asText();
}
if (page instanceof TextPage) {
return ((TextPage) page).getContent();
@@ -791,7 +796,7 @@
*/
BrowserVersion bv;
if (testContext.getUserAgent() != null) {
- bv = BrowserVersion.FIREFOX_3;
+ bv = BrowserVersion.FIREFOX_3_6;
bv.setUserAgent(testContext.getUserAgent());
} else {
bv = defaultBrowserVersion; // use default (which includes a full UserAgent string)
@@ -1462,8 +1467,8 @@
return false;
}
- public Table getTable(String tableSummaryOrId) {
- HtmlTable table = getHtmlTable(tableSummaryOrId);
+ public Table getTable(String tableSummaryNameOrId) {
+ HtmlTable table = getHtmlTable(tableSummaryNameOrId);
Table result = new Table();
for (int i = 0; i < table.getRowCount(); i++) {
Row newRow = new Row();
@@ -1480,31 +1485,37 @@
}
/**
- * Return the HttpUnit WebTable object representing a specified table in the current response. Null is returned if a
+ * Return the HtmlUnit WebTable object representing a specified table in the current response. Null is returned if a
* parsing exception occurs looking for the table or no table with the id or summary could be found.
*
- * @param tableSummaryOrId summary or id of the table to return.
+ * @param tableSummaryNameOrId summary or id of the table to return.
*/
- public HtmlTable getHtmlTable(String tableSummaryOrId) {
+ private HtmlTable getHtmlTable(String tableSummaryNameOrId) {
try {
return (HtmlTable) ((HtmlPage) win.getEnclosedPage())
- .getHtmlElementById(tableSummaryOrId);
+ .getHtmlElementById(tableSummaryNameOrId);
} catch (ElementNotFoundException e) {
-
+ //Not found
}
try {
return (HtmlTable) ((HtmlPage) win.getEnclosedPage())
.getDocumentElement().getOneHtmlElementByAttribute("table",
- "summary", tableSummaryOrId);
+ "summary", tableSummaryNameOrId);
} catch (ElementNotFoundException e) {
-
+ //Not found
}
+ try {
+ return (HtmlTable) ((HtmlPage) win.getEnclosedPage())
+ .getDocumentElement().getOneHtmlElementByAttribute("table",
+ "name", tableSummaryNameOrId);
+ } catch (ElementNotFoundException e) {
+ //Not found
+ }
return null;
}
- public boolean hasTable(String tableSummaryOrId) {
- HtmlTable table = getHtmlTable(tableSummaryOrId);
- return (table != null);
+ public boolean hasTable(String tableSummaryNameOrId) {
+ return getHtmlTable(tableSummaryNameOrId) != null;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2011-09-23 14:20:05
|
Revision: 918
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=918&view=rev
Author: henryju
Date: 2011-09-23 14:19:55 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
Support optgroup in getLabeledFieldValue. Minor cleanup in WebTester.
Modified Paths:
--------------
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
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 2011-09-23 14:17:12 UTC (rev 917)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2011-09-23 14:19:55 UTC (rev 918)
@@ -2757,7 +2757,7 @@
private IElement getLabel(String id) {
// get all labels
for (IElement e : getTestingEngine().getElementsByXPath("//label")) {
- if (e.getName().equals("label") && id.equals(e.getAttribute("id")))
+ if (id.equals(e.getAttribute("id")))
return e; // label found
}
return null;
@@ -2838,7 +2838,7 @@
*/
private void assertLabeledFieldEquals(String identifier, IElement label, String fieldText) {
String value = getLabeledFieldValue(identifier, label);
- assertEquals("value of field for label [" + identifier + "] should be [" + fieldText + "]", fieldText, value == null ? "" : value);
+ assertEquals("unexpected value of field for label [" + identifier + "]", fieldText, value == null ? "" : value);
}
/**
@@ -2883,12 +2883,20 @@
value = field.getTextContent();
} else if ("select".equals(field.getName())) {
// get the selected option
- for (IElement children : field.getChildren()) {
- if (children.getName().equals("option") && children.getAttribute("selected") != null) {
- value = children.getAttribute("value") == null ? children.getTextContent() : children.getAttribute("value");
- break;
- }
- }
+ for (IElement child : field.getChildren()) {
+ if (child.getName().equals("option") && child.getAttribute("selected") != null) {
+ value = child.getAttribute("value") == null ? child.getTextContent() : child.getAttribute("value");
+ break;
+ }
+ if (child.getName().equals("optgroup")) {
+ for (IElement subchild : child.getChildren()) {
+ if (subchild.getName().equals("option") && subchild.getAttribute("selected") != null) {
+ value = child.getAttribute("value") == null ? child.getTextContent() : child.getAttribute("value");
+ break;
+ }
+ }
+ }
+ }
} else {
throw new RuntimeException("Unexpected field type " + field.getName());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|