From 38b904b269d6c716cca8c3a3f216f1a5738d56c1 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sun, 26 May 2013 10:02:58 +0800 Subject: [PATCH] IDEMPIERE-92 Implement Selenium testing framework. Added phantomjs (phantomjs.org) support. --- org.idempiere.fitnesse.server/.classpath | 1 + .../META-INF/MANIFEST.MF | 4 +++- .../build.properties | 3 ++- .../META-INF/MANIFEST.MF | 1 + .../src/fitlibrary/zk/ZkFixture.java | 22 +++++++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/org.idempiere.fitnesse.server/.classpath b/org.idempiere.fitnesse.server/.classpath index 4bc6bacd9b..e096e1d2ed 100644 --- a/org.idempiere.fitnesse.server/.classpath +++ b/org.idempiere.fitnesse.server/.classpath @@ -1,6 +1,7 @@ + diff --git a/org.idempiere.fitnesse.server/META-INF/MANIFEST.MF b/org.idempiere.fitnesse.server/META-INF/MANIFEST.MF index 8a64d277da..f18501cbe8 100644 --- a/org.idempiere.fitnesse.server/META-INF/MANIFEST.MF +++ b/org.idempiere.fitnesse.server/META-INF/MANIFEST.MF @@ -18,7 +18,8 @@ Bundle-ClassPath: ., lib/fitnesse.jar, lib/log4j-1.2.16.jar, lib/fitlibraryweb-2.0.jar, - lib/selenium-server-standalone-2.31.0.jar + lib/selenium-server-standalone-2.31.0.jar, + lib/phantomjsdriver-1.0.3.jar Web-ContextPath: fitnesse Export-Package: fit, fit.decorator, @@ -300,6 +301,7 @@ Export-Package: fit, org.openqa.selenium.logging.profiler, org.openqa.selenium.net, org.openqa.selenium.os, + org.openqa.selenium.phantomjs, org.openqa.selenium.remote, org.openqa.selenium.remote.html5, org.openqa.selenium.remote.internal, diff --git a/org.idempiere.fitnesse.server/build.properties b/org.idempiere.fitnesse.server/build.properties index 9eb7375d71..2362a6b83f 100644 --- a/org.idempiere.fitnesse.server/build.properties +++ b/org.idempiere.fitnesse.server/build.properties @@ -7,4 +7,5 @@ bin.includes = META-INF/,\ lib/log4j-1.2.16.jar,\ lib/fitlibraryweb-2.0.jar,\ WEB-INF/,\ - lib/selenium-server-standalone-2.31.0.jar + lib/selenium-server-standalone-2.31.0.jar,\ + lib/phantomjsdriver-1.0.3.jar diff --git a/org.idempiere.ui.zk.selenium/META-INF/MANIFEST.MF b/org.idempiere.ui.zk.selenium/META-INF/MANIFEST.MF index 9a2d109ed9..4f9713f2df 100644 --- a/org.idempiere.ui.zk.selenium/META-INF/MANIFEST.MF +++ b/org.idempiere.ui.zk.selenium/META-INF/MANIFEST.MF @@ -301,6 +301,7 @@ Import-Package: fit, org.openqa.selenium.logging.profiler, org.openqa.selenium.net, org.openqa.selenium.os, + org.openqa.selenium.phantomjs, org.openqa.selenium.remote, org.openqa.selenium.remote.html5, org.openqa.selenium.remote.internal, diff --git a/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java b/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java index 8fac940180..f4f9a6c681 100644 --- a/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java +++ b/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java @@ -8,8 +8,11 @@ import java.util.List; import org.idempiere.ui.zk.selenium.Widget; import org.idempiere.ui.zk.selenium.Zk; import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.phantomjs.PhantomJSDriver; +import org.openqa.selenium.remote.DesiredCapabilities; import fitlibrary.annotation.SimpleAction; import fitlibrary.spider.AbstractSpiderFixture; @@ -272,6 +275,25 @@ public class ZkFixture extends SpiderFixture { + @Override + public WebDriver webDriver() { + if (webDriver == null) { + String driver = getDynamicVariable(WEB_DRIVER_VARIABLE_NAME,"htmlunit").toString(); + + if ("phantomjs".equals(driver)) { + webDriver = phantomjsDriver(); + return webDriver; + } + } + return super.webDriver(); + } + + private WebDriver phantomjsDriver() { + return new PhantomJSDriver(new DesiredCapabilities()); + } + + + class ZkFinder implements Finder { @Override