@Override
  public <T extends PageObject> T create(
      Class<T> pageClazz, PageObjectModel model, WebElement webElement) {

    try {

      T pageInstance = createInstance(pageClazz);
      initializeModel(pageInstance, model);
      initializeWebElement(pageInstance, webElement);

      initializeOtherPageObjectTypeFields(pageInstance, pageClazz);

      invokePostConstructMethods(pageInstance, pageClazz);
      checkVisibilityOfAnnotatedFields(pageInstance, pageClazz);

      return pageInstance;

    } catch (RuntimeException e) {
      EventSystem.fireEvent(new ExceptionEvent(model.getBrowser(), e));
      throw e;
    }
  }
Exemplo n.º 2
0
 /**
  * Fires the given event using the {@linkplain EventSystem#fireEvent(Event)} method and mark this
  * page object as used using {@linkplain Marker#markAsUsed(PageObject)}.
  *
  * @param event the event to fire.
  * @since 0.9.0
  */
 protected final void fireEventAndMarkAsUsed(Event event) {
   EventSystem.fireEvent(event);
   Marker.markAsUsed(this);
   logger.trace(logMessage("fired event: {}"), event);
 }