Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Adding a new page

mkrzyzanowski edited this page Nov 21, 2016 · 3 revisions

Using Author Pages in Touch UI

Defining test pages

Using author pages on Touch UI is basing on YAML configuration file named pages.yml in wchich we are defining pages we want to use. The file should be put under main/resources folder in your project. The single configuration entry for a page consists of three elements:

  • key - human-readable key for obtaining concrete page in test class
  • path - path to the page (without edit.html prefix)
  • parsys - path to parsys obtained form data-path attribute from it's DOM element (can be truncated up to /jcr:content)

Let's take a look at the example:

Text - Update&Read:
  path: /content/geometrixx/en/toolbar/search.html
  parsys: /par

The original data-path attribute of parsys is /content/geometrixx/en/toolbar/search/jcr:content/par but the part up to jcr:content is redundant. If you want to read more about providing data-path attributes please refer to Component descriptions tutorial.

Obtaining and using pages from configuration

To get instance of a page provided in configuration we need to use AuthorPageFactory instance which can be injected in your test class

@Inject
private AuthorPageFactory authorPageFactory;

Instance of this class can provide you a page using path. To get path of desired page from your configuration file you should use Pages class which can be injected in the same way as the factory above

@Inject
private Pages pages;

Now - all you need to do is to use that objects in a proper way:

import com.cognifide.qa.bb.aem.AemLogin;
import com.cognifide.qa.bb.aem.touch.data.pages.Pages;
import com.cognifide.qa.bb.aem.touch.pageobjects.pages.AuthorPage;
import com.cognifide.qa.bb.aem.touch.pageobjects.pages.AuthorPageFactory;
import com.cognifide.qa.bb.junit.TestRunner;
import com.cognifide.bdd.demo.GuiceModule;

//...

@RunWith(TestRunner.class)
@Modules(GuiceModule.class)
public class AemRichtextTest {
  @Inject
  private AemLogin aemLogin;

  @Inject
  private Pages pages;

  @Inject
  private AuthorPageFactory authorPageFactory;

  private AuthorPage page;

//..

  @Before
  public void before() {
    aemLogin.authorLogin();
    page = authorPageFactory.create(pages.getPath("Text - Update&Read"));
    page.open();
  }
//..
}

The Pages#getPath method is used to get page path from configuration key - in this case Text - Update&Read which we have defined in the very first section of this tutorial. The AuthorPageFactory#create method creates an AuthorPage instance which can be used for adding, deleting and configuring components in the parsys provided in the YAML configuration as well as getting content of the desired component. For details please take a look at the javadoc and further parts of AEM Touch UI tutorial.

Getting started with Bobcat

  1. Getting started

AEM Related Features

  1. Authoring tutorial - Classic
  1. AEM Classic Authoring Advanced usage
  1. Authoring tutorial - Touch UI
Clone this wiki locally