本文整理汇总了Java中play.test.TestBrowser类的典型用法代码示例。如果您正苦于以下问题:Java TestBrowser类的具体用法?Java TestBrowser怎么用?Java TestBrowser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestBrowser类属于play.test包,在下文中一共展示了TestBrowser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: navAdminFirefox17
import play.test.TestBrowser; //导入依赖的package包/类
/**
* @author andre.tschirch
*
* Example test method for using specific Firefox version e.g. v17.
*
* Test method for running a successful login and the right presentation of
* the activity state of the admin navigation link, which must be active,
* for browser Firefox.
*/
// @Test
public void navAdminFirefox17() {
ProfilesIni profile = new ProfilesIni();
FirefoxProfile firefoxProfile = profile.getProfile("firefox17");
WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("D:/schatzsuche/firefox17/firefox.exe")), firefoxProfile);
TestBrowser browser = Helpers.testBrowser(driver, 3333);
TestServer server = Helpers.testServer(3333, Helpers.fakeApplication());
TestServer startedServer = null;
try {
server.start();
startedServer = server;
new NavAdminCallbackComposite().invoke(browser);
} catch(Throwable t) {
throw new RuntimeException(t);
} finally {
if(browser != null) {
browser.quit();
}
if(startedServer != null) {
startedServer.stop();
}
}
}
示例2: testPerformLoginFail
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testPerformLoginFail() {
running(testServer(basePort, fakeApplication(inMemoryDatabase())), driver, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
performLoginActions(browser, configUsername, configPassword + "XXXX");
// check that the login failed message appears
assertThat(browser.pageSource()).contains(Domain.message("web.application.login.failed"));
// check that the application does not start
assertThat(browser.pageSource()).doesNotContain(Domain.message("web.application.notavailable"));
assertThat(browser.pageSource()).doesNotContain(Domain.message("web.application.layout.sidebar.dashboard"));
}
});
}
示例3: testIndexPage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testIndexPage() {
running(testServer(PORT, fakeApplication(inMemoryDatabase())), HTMLUNIT,
new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
IndexPage homePage = new IndexPage(browser.getDriver(), PORT);
// Check index page
browser.goTo(homePage);
homePage.isAt();
// check each other page, but before make sure to click on the index page again
browser.goTo(homePage);
homePage.gotoMakeOffer();
assertThat(homePage.title()).isEqualTo("Make an Offer");
browser.goTo(homePage);
homePage.gotoMakeRequest();
assertThat(homePage.title()).isEqualTo("Make a Request");
}
});
}
示例4: testBookCreatePage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testBookCreatePage() {
running(testServer(PORT, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
@Override
public void invoke(TestBrowser browser) {
// Create the pages.
BookCreatePage bookPage = new BookCreatePage(browser.getDriver(), PORT);
// Now test the page.
browser.goTo(bookPage);
bookPage.isAt();
String bookId = "Book-01";
bookPage.createNewBook(bookId);
// should redirect to book list
assertThat(bookPage.title()).isEqualTo("Student Book Exchange | Find Books");
assertThat(bookPage.pageSource()).contains(bookId);
}
});
}
示例5: testStudentCreatePage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testStudentCreatePage() {
running(testServer(PORT, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
@Override
public void invoke(TestBrowser browser) {
// Create the pages.
StudentCreatePage studentPage = new StudentCreatePage(browser.getDriver(), PORT);
// Now test the page.
browser.goTo(studentPage);
studentPage.isAt();
String studentId = "Student-01";
studentPage.createNewStudent(studentId);
// should redirect to student list
assertThat(studentPage.title()).isEqualTo("Student Book Exchange | Find Students");
assertThat(studentPage.pageSource()).contains(studentId);
}
});
}
示例6: testStudentCreatePage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testStudentCreatePage() {
running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT,
new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
StudentCreatePage studentCreatePage = new StudentCreatePage(browser.getDriver(), 3333);
BookIndexPage bookIndexPage = new BookIndexPage(browser.getDriver(), 3333);
StudentEditPage studentEditPage = new StudentEditPage(browser.getDriver(), 3333, 1L);
browser.goTo(studentCreatePage);
studentCreatePage.isAt();
studentCreatePage.makeNewStudent("Student-01", "Papa", "Smurf", "[email protected]",
"abc");
bookIndexPage.isAt();
browser.goTo(studentEditPage);
studentEditPage.isAt();
assertThat(studentEditPage.pageSource().contains("Student-01"));
// Testing the edit page here as well so we don't need create create the above student
studentEditPage.editStudent("Student-02", "Papa", "Smurf", "[email protected]", "abc");
bookIndexPage.isAt();
browser.goTo(studentEditPage);
assertThat(studentEditPage.pageSource().contains("Student-02"));
}
});
}
示例7: testRequestCreatePage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testRequestCreatePage() {
running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT,
new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
// Make sure a student is logged in (hack, but it's late)
StudentCreatePage studentCreatePage = new StudentCreatePage(browser.getDriver(), 3333);
browser.goTo(studentCreatePage);
studentCreatePage.isAt();
studentCreatePage.makeNewStudent("Student-01", "Papa", "Smurf", "[email protected]",
"abc");
RequestPage requestPage = new RequestPage(browser.getDriver(), 3333);
RequestCreatePage requestCreatePage = new RequestCreatePage(browser.getDriver(), 3333);
browser.goTo(requestCreatePage);
requestCreatePage.isAt();
requestCreatePage.makeNewRequest("Request-01", "Book-01", "Book", "Edition", "1234",
"20", "Good");
requestPage.isAt();
assertThat(requestPage.pageSource().contains("Book"));
}
});
}
示例8: testIndexPage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testIndexPage () {
Map<String, String> settings = new HashMap<String, String>();
settings.putAll(inMemoryDatabase());
settings.put("DemoData", "true");
running(testServer(3333, fakeApplication(settings)), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
IndexPage homePage = new IndexPage(browser.getDriver(), 3333);
browser.goTo(homePage);
homePage.isAt();
homePage.gotoNewWarehouse();
homePage.gotoHome();
}
});
}
示例9: testMyOffersPage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testMyOffersPage () {
Map<String, String> settings = new HashMap<String, String>();
settings.putAll(inMemoryDatabase());
settings.put("DemoData", "true");
running(testServer(3333, fakeApplication(settings)), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
MyOffersPage offersPage = new MyOffersPage(browser.getDriver(), 3333);
browser.goTo(offersPage);
offersPage.isAt();
offersPage.makeNewOffer("Java Concepts", "Used", "22.15");
assertThat(offersPage.pageSource()).contains("Offer Created.");
String noWhiteSpace = offersPage.pageSource().replaceAll("\\s","");
assertThat(noWhiteSpace.contains("<td>JavaConcepts</td><td>Used</td>"));
assertThat(noWhiteSpace.contains("value=22.15"));
offersPage.isAt();
}
});
}
示例10: testMyRequestsPage
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void testMyRequestsPage () {
Map<String, String> settings = new HashMap<String, String>();
settings.putAll(inMemoryDatabase());
settings.put("DemoData", "true");
running(testServer(3333, fakeApplication(settings)), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
MyRequestsPage requestsPage = new MyRequestsPage(browser.getDriver(), 3333);
browser.goTo(requestsPage);
requestsPage.isAt();
requestsPage.makeNewOffer("Java Concepts", "Used", "22.15");
assertThat(requestsPage.pageSource()).contains("Request Created.");
String noWhiteSpace = requestsPage.pageSource().replaceAll("\\s","");
assertThat(noWhiteSpace.contains("<td>JavaConcepts</td><td>Used</td>"));
assertThat(noWhiteSpace.contains("value=22.15"));
requestsPage.isAt();
}
});
}
示例11: invoke
import play.test.TestBrowser; //导入依赖的package包/类
@Override
public void invoke(TestBrowser browser) throws Throwable {
browser.goTo("http://localhost:3333/").await().atMost(10000);
// select german language
browser.click("#a-de").await().atMost(10000);
// fill the user name
browser.fill("#username").with(" s");
browser.await().atMost(10000);
// submit the form
browser.click("#btn-start").await().atMost(10000);
// correct error message
assertThat(browser.pageSource())
.contains(
play.i18n.Messages.get("common.index.login.username.error"));
}
示例12: invoke
import play.test.TestBrowser; //导入依赖的package包/类
/**
* Der Testfall verlangt nach erfolgreicher Registrierung das Vorhandensein
* von "registrationSuccess" im HTML-Content.
*/
@Override
public void invoke(TestBrowser browser) throws Throwable {
browser.goTo("http://localhost:3333/signup");
browser.fill("#name").with("stefan");
browser.fill("#email").with("[email protected]");
browser.fill("#password").with("55555");
browser.fill("#repeatPassword").with("55555");
syncWaitFor(1);
browser.submit("#registerBtn");
syncWaitFor(1);
String verificationURL = getVerifikationURL();
System.out.println("Verification-URL: " + verificationURL);
browser.goTo(verificationURL);
syncWaitFor(1);
assertThat(browser.pageSource()).contains("registrationSuccess");
}
示例13: test
import play.test.TestBrowser; //导入依赖的package包/类
/**
* add your integration test here
* in this example we just check if the welcome page is being shown
*/
@Test
public void test() {
running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
browser.goTo("http://localhost:3333");
assertTrue(browser.pageSource().contains("Your new application is ready."));
}
});
}
示例14: threadLocalContextShouldBeSet
import play.test.TestBrowser; //导入依赖的package包/类
@Test
public void threadLocalContextShouldBeSet() {
running(testServer(9001), HTMLUNIT, new F.Callback<TestBrowser>() {
@Override
public void invoke(TestBrowser testBrowser) throws Throwable {
testBrowser.goTo("http://localhost:9001/this/path/not/found");
Cookie sessionCookie = testBrowser.getCookie(Session$.MODULE$.COOKIE_NAME());
assertThat(sessionCookie).isNotNull();
assertThat(sessionCookie.getValue()).contains("onHandlerNotFound");
}
});
}
示例15: test
import play.test.TestBrowser; //导入依赖的package包/类
/**
* add your integration test here
* in this example we just check if the welcome page is being shown
*/
@Test
public void test() {
running(testServer(3333, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) {
browser.goTo("http://localhost:3333");
assertThat(browser.pageSource()).contains("Your new application is ready.");
}
});
}