From ccc7c1e6e31d66746abf2d3dbb38be001c11ed23 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 11 Jun 2013 23:52:07 +0800 Subject: [PATCH] IDEMPIERE-92 Implement Selenium testing framework. Added default screen size for phantomjs driver. Added "screen shot" and "maximize window" commands to aids debugging of selenium test script. --- .../src/fitlibrary/zk/ZkFixture.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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 f2ec5043a4..7218a029b1 100644 --- a/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java +++ b/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java @@ -8,10 +8,14 @@ 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.Dimension; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TakesScreenshot; 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.Augmenter; import org.openqa.selenium.remote.DesiredCapabilities; import fitlibrary.annotation.SimpleAction; @@ -286,9 +290,34 @@ public class ZkFixture extends SpiderFixture { } return super.webDriver(); } + + public void screenShot() { + if (webDriver instanceof TakesScreenshot) + { + String s = ((TakesScreenshot)webDriver).getScreenshotAs(OutputType.BASE64); + show(""); + } + else + { + Augmenter augmenter = new Augmenter(); + TakesScreenshot ts = (TakesScreenshot) augmenter.augment(webDriver); + String s = ts.getScreenshotAs(OutputType.BASE64); + show(""); + } + } + public void maximizeWindow() { + webDriver.manage().window().maximize(); + } + private WebDriver phantomjsDriver() { - return new PhantomJSDriver(new DesiredCapabilities()); + DesiredCapabilities caps = new DesiredCapabilities(); + caps.setJavascriptEnabled(true); + caps.setCapability("takesScreenshot", true); + PhantomJSDriver driver = new PhantomJSDriver(caps); + //set default resolution + driver.manage().window().setSize(new Dimension(1366, 768)); + return driver; }