How to abort an HTTP method before its normal completion

  • 13
    Jul

    How to abort an HTTP method before its normal completion

    Following example demonstrates how to abort a HttpClient connection (based on condition) and finally close it manually import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; public class AbortWithHttpClient {...

    Read More
  • 12
    Jul

    Convert a String to Date type with LocalDate

    // converting a String in dd-mmm-yyyy format (e.g. 06-Sep-2018) to dd-MMM-yyyy format String dateString = “21-Aug-1979”; LocalDate parsed = DateTimeFormatter.ofPattern(“dd-MMM-yyyy”).parse(dateString); // from java.time.LocalDate into java.lang.String LocalDate localDate = LocalDate.now();...

    Read More
  • 12
    Jul

    Extracting images from a PDF File – org.apache.pdfbox

    Maven dependency configuration org.apache.pdfbox pdfbox 2.0.8 This application extracts images from a PDF document. We loop over each page and get all the resources. Next we iterate over each...

    Read More
  • 09
    Jul

    Get CssValue / Attribute of an WebElement in selenium

    Sometimes it is necessary to get the Attribute / run time value of Css property of a WebElement. We can use following code-snippet to get run time value of...

    Read More
  • 06
    Jul

    Defining data for POM pages elements

    Rules for POJO in java 1. Class needs to be Public 2. Properties are Private 3. Every property should have public getter and setters 4. Public default constructor Mandatory...

    Read More
  • 06
    Jul

    Creating a global context for your automation run

    Many a time we see scripts have to refer many global variable and modify per script execution requirements. Following code snippet allows an end user to define global variables...

    Read More
  • 06
    Jul

    XPath in Winium

    Following code snippet demonstrates how to use XPath with Winium driver. WebElement testElement = winiumdriver.findElement(By.xpath(“//*[contains(@Name,’Keys: ‘)]”)); String lblValue = testElement.getAttribute(“Name”); System.out.println(lblValue); Unfortunately Winium driver do not support CSS elements...

    Read More
  • 06
    Jul

    Get display text of label in Winium

    We can interact with Labels in desktop application by using following code: WebElement testElement = winiumdriver.findElement(By.xpath(“//*[contains(@Name,’Keys: ‘)]”)); String lblValue = testElement.getAttribute(“Name”); System.out.println(lblValue);

    Read More
  • 06
    Jul

    Launch desktop application with Winium

    Following code snippet launches desktop application – import java.io.File; import java.io.IOException; import org.openqa.selenium.winium.DesktopOptions; import org.openqa.selenium.winium.WiniumDriver; import org.openqa.selenium.winium.WiniumDriverService; public class LaunchWinium { public static WiniumDriver driver; static String outlookApplicationPath =...

    Read More
  • 06
    Jul

    Switching focus in winium

    In order to switch between two windows / apps (initialized with winium driver), one can switch between two desktop windows by using following code snippet: WebElement nextWindow = winiumdriver.findElementByName(“Window...

    Read More