forked from stephenh/pageobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
5 changed files
with
52 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters