Class PdfViewerElement

java.lang.Object
com.vaadin.testbench.TestBenchElement
com.vaadin.flow.component.pdfviewer.testbench.PdfViewerElement
All Implemented Interfaces:
CanCompareScreenshots, HasCallFunction, HasDriver, HasElementQuery, HasPropertySettersGetters, HasSearchContext, HasTestBenchCommandExecutor, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebElement, org.openqa.selenium.WrapsElement

public class PdfViewerElement extends TestBenchElement
A TestBench element representing a <vaadin-pdf-viewer> element.
  • Constructor Details

    • PdfViewerElement

      public PdfViewerElement()
  • Method Details

    • getSrc

      public String getSrc()
      Gets the URL of the document.
      Returns:
      the URL of the document, or null if no document is set
    • getHeaderTitle

      public String getHeaderTitle()
      Gets the title shown in the header of the viewer.
      Returns:
      the title shown in the header
    • isToolbarCollapsed

      public boolean isToolbarCollapsed()
      Checks whether the toolbar is collapsed.
      Returns:
      true if the toolbar is collapsed, false otherwise
    • toggleToolbar

      public void toggleToolbar()
      Collapses the toolbar if it is expanded, or expands it if it is collapsed, by clicking the header of the viewer.
    • getPage

      public int getPage()
      Gets the current page, which is the page that takes up most of the visible area.
      Returns:
      the current page, starting from 1
    • getPageCount

      public int getPageCount()
      Gets the number of pages in the loaded document.
      Returns:
      the number of pages, or 0 if no document is loaded
    • getZoom

      public String getZoom()
      Gets the zoom level of the pages.
      Returns:
      page-width, page-fit, or the factor of the actual size of the pages
    • setZoom

      public void setZoom(PdfViewerElement.ZoomMode mode)
      Sets the zoom to a mode that fits the pages to the viewer.
      Parameters:
      mode - the zoom mode
    • setZoom

      public void setZoom(double factor)
      Sets the zoom to a factor of the actual size of the pages, for example 1 for 100% and 1.5 for 150%.
      Parameters:
      factor - the factor of the actual size of the pages, greater than 0
    • zoomIn

      public void zoomIn()
      Zooms in to the next zoom level with the zoom in button of the toolbar.
    • zoomOut

      public void zoomOut()
      Zooms out to the previous zoom level with the zoom out button of the toolbar.
    • isLoading

      public boolean isLoading()
      Checks whether a document is being loaded.
      Returns:
      true if a document is being loaded, false otherwise
    • hasError

      public boolean hasError()
      Checks whether the document could not be loaded.
      Returns:
      true if the document could not be loaded, false otherwise