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

AemContentFinder

Daniel Madejek edited this page Jul 13, 2016 · 2 revisions

#Aem Content Finder

Introduction

AEM page in classic authoring mode has Content Finder. Bobcat allows to access it by using AemContentFinder class

How to use it

All methods are described in javadoc

@Inject
private AemContentFinder contentFinder;

AemContentFinder can be injected into test or page

contentFinder.clickTab("Images");

Switching tabs using their names

contentFinder.search("");

Using search field

contentFinder.getResults();

Retrieving search results

contentFinder.getElementByIndex(0)

Retriving first element from list

Test example

This test uses AemContentFinder to change image in Image component

package example;

import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.cognifide.qa.bb.aem.ui.AemContentFinder;
import com.cognifide.qa.bb.junit.Modules;
import com.cognifide.qa.bb.junit.TestRunner;
import com.cognifide.qa.bb.provider.selenium.BobcatWait;
import com.google.inject.Inject;

import example.GuiceModule;
import example.pageobjects.login.LoginPage;
import example.pageobjects.summer.ImageComponent;
import example.pageobjects.summer.SummerBlockbusterHitsPage;

@RunWith(TestRunner.class)
@Modules(GuiceModule.class)
public class ImageComponentTest {

  @Inject
  private LoginPage loginPage;

  @Inject
  private SummerBlockbusterHitsPage page;

  @Inject
  private AemContentFinder contentFinder;

  private ImageComponent imageComponent;

  @AfterClass()
  public static void afterClass() {
    BobcatWait.sleep(1);
  }

  @Before
  public void before() {
    logIn();
    openPageToTest();
    imageComponent = page.getImageComponent();
  }

  private void openPageToTest() {
    page.open();
    assertTrue("Page is not displayed", page.isDisplayed());
  }

  private void logIn() {
    assertTrue("Login page is not displayed", loginPage.loginAsAuthor().isDisplayed());
  }

  @Test
  public void insertImageTest() {
    contentFinder.clickTab("Images");
    contentFinder.search("");
    List<String> results = contentFinder.getResults();
    if (results.size() > 0) {
      imageComponent.getDialog().open();
      imageComponent.insert(contentFinder.getElementByIndex(0));
      imageComponent.getDialog().ok();
      assertTrue("Image not found",
          results.get(0).contains(imageComponent.getImgAttribute("title")));
    }

  }
}

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