From 91b7fd2ee841a94c7470335a932d997173ff45b1 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Tue, 1 Oct 2013 14:57:30 -0500 Subject: [PATCH 1/4] Fix upload location. --- buildfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildfile b/buildfile index 5a2c564..53d43f5 100644 --- a/buildfile +++ b/buildfile @@ -4,7 +4,7 @@ require 'buildr/ivy_extension' VERSION_NUMBER = ENV['version'] || 'SNAPSHOT' repositories.remote << "http://repo1.maven.org/maven2/" -repositories.release_to = 'sftp://joist.ws/var/joist.repo' +repositories.release_to = 'sftp://joist.ws/var/www/joist.repo' repositories.release_to[:permissions] = 0644 # to resolve the ${version} in the ivy.xml From e652790c20b491a89ce4c0aaff9424a757350f16 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 23 Nov 2013 23:42:52 -0600 Subject: [PATCH 2/4] Change TextObject.nowHasText to use Selenium's ExpectedCondition. --- ivy.xml | 2 +- .../java/com/bizo/pageobjects/TextObject.java | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ivy.xml b/ivy.xml index d16e3c7..9930ea9 100644 --- a/ivy.xml +++ b/ivy.xml @@ -6,7 +6,7 @@ - + diff --git a/src/main/java/com/bizo/pageobjects/TextObject.java b/src/main/java/com/bizo/pageobjects/TextObject.java index 73acd89..ad8629a 100644 --- a/src/main/java/com/bizo/pageobjects/TextObject.java +++ b/src/main/java/com/bizo/pageobjects/TextObject.java @@ -4,8 +4,9 @@ import static org.junit.Assert.assertThat; import org.openqa.selenium.By; - -import com.google.common.base.Supplier; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedCondition; public class TextObject extends AbstractElementObject { @@ -29,12 +30,18 @@ public void assertText(final String text) { assertThat(get(), is(text)); } - public Supplier nowHasText(final String text) { - return new Supplier() { - public Boolean get() { - return text.equals(TextObject.this.get()); + public ExpectedCondition nowHasText(final String text) { + return new ExpectedCondition() { + public Boolean apply(WebDriver input) { + return text.equals(get()); } }; } + private static String getHiddenText(final WebDriver d, final String elementId) { + return (String) ((JavascriptExecutor) d).executeScript(// + "var d = document.getElementById('" + elementId + "'); return (d == null) ? '' : d.innerHTML;"); + } + + } From c69ded20bec97086f8e31a3bb3fd57c0965f1660 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 23 Nov 2013 23:43:08 -0600 Subject: [PATCH 3/4] Remove unused FileBoxObject.id field. --- src/main/java/com/bizo/pageobjects/FileBoxObject.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/bizo/pageobjects/FileBoxObject.java b/src/main/java/com/bizo/pageobjects/FileBoxObject.java index 8d33717..3438ad5 100644 --- a/src/main/java/com/bizo/pageobjects/FileBoxObject.java +++ b/src/main/java/com/bizo/pageobjects/FileBoxObject.java @@ -4,12 +4,9 @@ public class FileBoxObject extends AbstractElementObject { - private final String id; - /** Only take an id for our firefox change hack. */ public FileBoxObject(final PageObject p, final String id) { super(p, id); - this.id = id; } public void set(File file) { From aa2f6814d32eacdae9a5a0d9446bad307d23c281 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 23 Nov 2013 23:43:38 -0600 Subject: [PATCH 4/4] Add a HiddenObject for getting at off-screen debug text. --- .../com/bizo/pageobjects/HiddenObject.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/com/bizo/pageobjects/HiddenObject.java diff --git a/src/main/java/com/bizo/pageobjects/HiddenObject.java b/src/main/java/com/bizo/pageobjects/HiddenObject.java new file mode 100644 index 0000000..12ac7b4 --- /dev/null +++ b/src/main/java/com/bizo/pageobjects/HiddenObject.java @@ -0,0 +1,37 @@ +package com.bizo.pageobjects; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedCondition; + +/** A class to get the text of off-screen/debug elements that are otherwise hidden. */ +public class HiddenObject extends AbstractElementObject { + + private final String id; + + public HiddenObject(final PageObject p, final String id) { + super(p, id); + this.id = id; + } + + public String get() { + return (String) ((JavascriptExecutor) getWebDriver()).executeScript(// + "var d = document.getElementById('" + id + "'); return (d == null) ? '' : d.innerHTML;"); + } + + public void assertText(final String text) { + assertThat(get(), is(text)); + } + + public ExpectedCondition nowHasText(final String text) { + return new ExpectedCondition() { + public Boolean apply(WebDriver input) { + return text.equals(get()); + } + }; + } + +}