Created
March 19, 2012 11:07
-
-
Save raphaelbauer/2107757 to your computer and use it in GitHub Desktop.
Testexample - possible Play 2 bug
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
package testexamples; | |
import static org.fest.assertions.Assertions.assertThat; | |
import static play.test.Helpers.HTMLUNIT; | |
import static play.test.Helpers.running; | |
import static play.test.Helpers.testServer; | |
import org.junit.Test; | |
import play.libs.F.Callback; | |
import play.test.TestBrowser; | |
/** | |
* | |
* full htmlunit running stuff... | |
* => selenium testcase, but with a better syntax... and without the fuzz | |
* | |
* syntax is at: | |
* https://github.com/FluentLenium/FluentLenium | |
* | |
* =========== | |
* DOES NOT YET WORK FOR GWT => HTMLUNIT MUST BE CONFIGURED BY THAT => RAPHAEL SHOULD DO THAT AS HE | |
* HAS DONE THAT ALREADY | |
* =========== | |
* | |
*/ | |
public class ServerHtmlUnitTest { | |
@Test | |
public void runInBrowser() { | |
running(testServer(3333), HTMLUNIT, new Callback<TestBrowser>() { | |
@Override | |
public void invoke(TestBrowser browser) { | |
browser.goTo("http://localhost:3333"); | |
System.out.println(browser.pageSource()); | |
assertThat(browser.pageSource()).contains("nocache.js"); | |
// FROM THE DOCS: | |
// browser.await().atMost(10, TimeUnit.SECONDS).until(".GLW4UNRDMNB").withText( | |
// "Dr Kevin Fong").isPresent(); | |
// System.out.println(browser.pageSource()); | |
// browser.pageSource().contains("Fong")); | |
// System.out.println("test: " + browser.$("#title").getTexts().get(0)); | |
// assertThat(browser.$("#title").getTexts().get(0)).isEqualTo("Hello Guest"); | |
// browser.$("a").click(); | |
// assertThat(browser.url()).isEqualTo("http://localhost:3333/Coco"); | |
// assertThat(browser.$("#title", 0).getText()).isEqualTo("Hello Coco"); | |
} | |
}); | |
} | |
@Test | |
public void runInBrowser2() { | |
running(testServer(3333), HTMLUNIT, new Callback<TestBrowser>() { | |
@Override | |
public void invoke(TestBrowser browser) { | |
browser.goTo("http://localhost:3333"); | |
System.out.println(browser.pageSource()); | |
assertThat(browser.pageSource()).contains("nocache.js"); | |
// FROM THE DOCS: | |
// browser.await().atMost(10, TimeUnit.SECONDS).until(".GLW4UNRDMNB").withText( | |
// "Dr Kevin Fong").isPresent(); | |
// System.out.println(browser.pageSource()); | |
// browser.pageSource().contains("Fong")); | |
// System.out.println("test: " + browser.$("#title").getTexts().get(0)); | |
// assertThat(browser.$("#title").getTexts().get(0)).isEqualTo("Hello Guest"); | |
// browser.$("a").click(); | |
// assertThat(browser.url()).isEqualTo("http://localhost:3333/Coco"); | |
// assertThat(browser.$("#title", 0).getText()).isEqualTo("Hello Coco"); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment