top of page

Berk Client (Java)


The Berk Client sends a screenshot and element image to the Berk Server, which then returns the coordinates of the element in the screenshot. Communication is done over default port 5003.
 

Setup

 Maven: You can get the latest jar file from hereMaven Repo

<dependency>
  <groupId>ai.berktest</groupId>
  <artifactId>BerkClient</artifactId>
  <version>latest</version>
</dependency>

 
Creating an Instance
 

You can instantiate the Berk class in several ways depending on your requirements:

  • With a WebDriver instance, host, and port:


    String host = "http://0.0.0.0:";  (Berk Server Hos)t
    String port = "5003";
    Berk berk = new Berk(driver, host, port);
     

  • With a host: (Port will be default)

    String host = "http://0.0.0.0:";
    Berk berk = new Berk(host);
     

  • With a WebDriver instance: (Host and Port will be default)

    Berk berk = new Berk(driver);
     

  • Without any parameters:

    Berk berk = new Berk();

     

Key Methods

getCenterCoordinates

Obtains the center coordinates of an element.

 e.g. : List<Integer> centerCoordinates = berk.getCenterCoordinates(driver, "elementPath", 10);

waitUntilElementDisplayed

Waits for an element to be displayed within a specified time.

  e.g. : boolean isDisplayed = berk.waitUntilElementDisplayed(driver, "elementPath", 10);

ifElementDisplayedGetCoordinates

Checks if an element is displayed and returns its coordinates.

  e.g. : Map<Boolean, BerkResponse> response = berk.ifElementDisplayedGetCoordinates(driver, "elementPath", 10);

 
click

Clicks on a specified element.

  e.g. : berk.click(driver, "elementName", 10);

 
takeScreenshot

Takes a screenshot of the current view of the WebDriver.

  e.g. :  berk.takeScreenshot(driver);

scrollUntilElementDisplayed

Scrolls until a specified element is displayed.

  e.g. : berk.scrollUntilElementDisplayed(driver, "elementPath");

sendKeys

Sends keys to a specified element.

  e.g. :  berk.sendKeys((AppiumDriver) driver, "elementPath", "text", 10);
 

bottom of page