Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
* master:
  Add a HiddenObject for getting at off-screen debug text.
  Remove unused FileBoxObject.id field.
  Change TextObject.nowHasText to use Selenium's ExpectedCondition.
  Fix upload location.
  • Loading branch information
Stephen Haberman committed Nov 24, 2013
2 parents 7580aba + aa2f681 commit 24e0b46
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 11 deletions.
2 changes: 1 addition & 1 deletion buildfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<conf name="sources"/>
</configurations>
<dependencies defaultconfmapping="%->default;sources->sources()">
<dependency org="org.seleniumhq.selenium" name="selenium-java" rev="2.16.1" conf="compile;sources" />
<dependency org="org.seleniumhq.selenium" name="selenium-java" rev="2.37.0" conf="compile;sources" />
<dependency org="junit" name="junit" rev="4.8.1" conf="compile;sources" />
</dependencies>
</ivy-module>
3 changes: 0 additions & 3 deletions src/main/java/com/bizo/pageobjects/FileBoxObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/bizo/pageobjects/HiddenObject.java
Original file line number Diff line number Diff line change
@@ -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<Boolean> nowHasText(final String text) {
return new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver input) {
return text.equals(get());
}
};
}

}
19 changes: 13 additions & 6 deletions src/main/java/com/bizo/pageobjects/TextObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -29,12 +30,18 @@ public void assertText(final String text) {
assertThat(get(), is(text));
}

public Supplier<Boolean> nowHasText(final String text) {
return new Supplier<Boolean>() {
public Boolean get() {
return text.equals(TextObject.this.get());
public ExpectedCondition<Boolean> nowHasText(final String text) {
return new ExpectedCondition<Boolean>() {
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;");
}


}

0 comments on commit 24e0b46

Please sign in to comment.