Class WebUtilsSelenium

java.lang.Object
de.frankmuenster.mahoe.utils.WebUtilsSelenium

public final class WebUtilsSelenium extends Object
Utility class for web methods
Author:
Frank Münster
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getAsJson(org.openqa.selenium.WebDriver webClient)
    Return plain json.
    static byte[]
    getSeleniumPdfAsByteArray(org.openqa.selenium.WebDriver driver, String url)
    Read the account statement PDF into a byte array.
    static byte[]
    getSeleniumPdfAsByteArray(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement linkElement)
    Deprecated.
    from 2.6.2.
    static byte[]
    getSeleniumPdfAsByteArray(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement linkElement, String expectedFileName)
    Read the account statement PDF into a byte array.
    static boolean
    isWindowStillOpen(org.openqa.selenium.WebDriver webClient, String popupHandle2)
    Check if the window for a given handle is still open
    static void
    scrollTo(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement element)
    Scroll to an element so it is visible at the top on top
    static void
    scrollTo(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement element, boolean scrollTo)
    Scroll to an element so it is visible at scrollTo position
    static org.openqa.selenium.support.ui.ExpectedCondition<Boolean>
    textToBePresentInElement(org.openqa.selenium.WebElement element, String text)
    Waits for a text to be present as part of a field
    static boolean
    webResponseIsJson(org.openqa.selenium.WebDriver webClient)
    Überprüft die Webantwort, ob der http Statuscode 200 ist und die Antwort im JSON-Format vorliegt.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getAsJson

      public static String getAsJson(org.openqa.selenium.WebDriver webClient)
      Return plain json. Bo checks are performed!!!!
    • getSeleniumPdfAsByteArray

      public static byte[] getSeleniumPdfAsByteArray(org.openqa.selenium.WebDriver driver, String url) throws WebSiteException
      Read the account statement PDF into a byte array.
      Parameters:
      driver - the WebDriver to use
      linkElement - the link on the page to the PDF
      expectedFileName -
      Returns:
      the PDF as byte array
      Throws:
      WebSiteException
    • getSeleniumPdfAsByteArray

      @Deprecated public static byte[] getSeleniumPdfAsByteArray(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement linkElement) throws WebSiteException
      Deprecated.
      from 2.6.2.
      Please replace with {@link getSeleniumPdfAsByteArray(final WebDriver driver, final String url)} to avoid stale elements.
      Read the account statement PDF into a byte array.
      Parameters:
      driver - the WebDriver to use
      linkElement - the link on the page to the PDF
      expectedFileName -
      Returns:
      the PDF as byte array
      Throws:
      WebSiteException
    • getSeleniumPdfAsByteArray

      public static byte[] getSeleniumPdfAsByteArray(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement linkElement, String expectedFileName)
      Read the account statement PDF into a byte array.
      Parameters:
      driver - the WebDriver to use
      linkElement - the link on the page to the PDF
      expectedFileName -
      Returns:
      the PDF as byte array
    • isWindowStillOpen

      public static boolean isWindowStillOpen(org.openqa.selenium.WebDriver webClient, String popupHandle2)
      Check if the window for a given handle is still open
    • scrollTo

      public static void scrollTo(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement element)
      Scroll to an element so it is visible at the top on top
    • scrollTo

      public static void scrollTo(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement element, boolean scrollTo)
      Scroll to an element so it is visible at scrollTo position
      Parameters:
      scrollTo - true top of element on top of view area, false bottom of element on bottom of view area
    • textToBePresentInElement

      public static org.openqa.selenium.support.ui.ExpectedCondition<Boolean> textToBePresentInElement(org.openqa.selenium.WebElement element, String text)
      Waits for a text to be present as part of a field
      Parameters:
      element - the element the text should appear
      text - the text to wait for
      Returns:
      true if the text was found, false else
    • webResponseIsJson

      public static boolean webResponseIsJson(org.openqa.selenium.WebDriver webClient)
      Überprüft die Webantwort, ob der http Statuscode 200 ist und die Antwort im JSON-Format vorliegt.
      Parameters:
      webResponse -
      Returns:
      true wenn HHTP code 200 und Antwortinhalt application/json ist, sonst false.