This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
AEM Create Page
Mikołaj Mański edited this page Jul 26, 2016
·
1 revision
Bobcat provides simple way to login into AEM and create a page
@Inject
private SiteAdminPage page;
@Inject
private AemLogin aemLogin;
Using GUICE we inject SiteAdminPage which represents siteadmin page in AEM. Second object is AemLogin resposible for login into instance
@Before
public void openSiteadminPage() {
aemLogin.authorLogin();
page.open(BASE_PARENT_URL);
}
Before test starts we have to login into AEM (AemLogin.authorLogin() uses properties defined in instances.properties) and open siteadmin. URL in open method allows to define on which level siteadmin will be opened
if (!page.isPagePresent(CREATED_PAGE_TITLE)) {
page.createNewPage(CREATED_PAGE_TITLE, CREATE_PAGE_TEMPLATE);
}
First we check if page we want to create already exist. Then we create new page, first argument is page title, second name of template we want to use
if (page.isPagePresent(pageTitle)) {
page.deletePage(pageTitle);
}
To cleanup after test we just delete created page if it exists
This is a simple test which logins into author instance, creates page and cleans after it is finished
package com.cognifide.bobcat.examples;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.cognifide.qa.bb.aem.AemLogin;
import com.cognifide.qa.bb.aem.ui.wcm.SiteAdminPage;
import com.cognifide.qa.bb.junit.Modules;
import com.cognifide.qa.bb.junit.TestRunner;
import com.google.inject.Inject;
@RunWith(TestRunner.class)
@Modules(GuiceModule.class)
public class CreatePageTest {
private static final String CREATE_PAGE_TEMPLATE = "Media Article";
private static final String BASE_PARENT_URL = "/content/geometrixx-media/en/entertainment";
private static final String CREATED_PAGE_TITLE = "What is bobcat";
@Inject
private SiteAdminPage page;
@Inject
private AemLogin aemLogin;
@Before
public void openSiteadminPage() {
aemLogin.authorLogin();
page.open(BASE_PARENT_URL);
}
@Test
public void createPage() {
if (!page.isPagePresent(CREATED_PAGE_TITLE)) {
page.createNewPage(CREATED_PAGE_TITLE, CREATE_PAGE_TEMPLATE);
}
assertTrue(page.isPagePresent(CREATED_PAGE_TITLE));
assertTrue(page.isTemplateOnTheList(CREATED_PAGE_TITLE, CREATE_PAGE_TEMPLATE));
}
@After
public void cleanUp() {
removePage(BASE_PARENT_URL, CREATED_PAGE_TITLE);
}
private void removePage(String parentPath, String pageTitle) {
page.open(parentPath);
if (page.isPagePresent(pageTitle)) {
page.deletePage(pageTitle);
}
}
}
- Configuring Bobcat
- Selenium enhancements
- Cucumber enhancements
- Traffic analyzer
- Email support
- Reporting
- Cloud integration
- Mobile integration
- Executing tests on different environments
- Working with multiple threads
- Tips and tricks
- Authoring tutorial - Classic
- AEM Classic Authoring Advanced usage
- Siteadmin
- Sidekick
- Aem Component
- Working with author pages
- Working with Publish pages
- Advanced component interactions
- Working with Context Menu
- Using Aem Content Tree
- Aem Content Finder
- Storing component configurations
- Working with packages
- Jcr Support
- Authoring tutorial - Touch UI
- Adding and editing a component
- Sites management tutorial