Before starting Automation with Testproject.io we need to have a account with them. To Signup with testproject.io you can click here. If you have already registered with testproject Download and install an Agent for your operating system or pull a container from Docker Hub.

After the Test Agent is up and running we need to decide the test type. i.e Web , Mobile or Code.I’m going to share all three ways .

testproject.io , selecting test type code in testproject.io
  1. Integrating it with Java SDK

To start using the SDK , we need to have a developer token .Get a development token from Integrations / SDK page.

You must have Java Development Kit (JDK) 11 or newer installed.

Once you are done till here , next thing is configuring our IDE. I’m using InteliJ for this post.Create a new Maven project in IDE and add the following two dependencies.Make sure to use JDK 11 or above.

Open the POM.xml file and add the following dependencies.

<dependencies>
     <dependency>
         <groupId>io.testproject</groupId>
         <artifactId>java-sdk</artifactId>
         <version>0.64.1-RELEASE</version>
     </dependency>
     <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
     <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>1.7.30</version>
     </dependency>

 </dependencies>

Once the dependencies are added , we will create out first class and let’s name this class as WebTest.java and add the following code.Before running the code , make sure the Agent is running.

import io.testproject.sdk.DriverBuilder;
import io.testproject.sdk.drivers.web.ChromeDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeOptions;

import java.net.URL;

public class WebTest {

    public static void main(final String[] args) throws Exception {
        ChromeDriver driver = new DriverBuilder<ChromeDriver>(new ChromeOptions())
                .withToken("YOUR_DEV_TOKEN")
                .build(ChromeDriver.class);
        driver.navigate().to("https://example.testproject.io/web/");
       // ChromeDriver driver = new ChromeDriver(new ChromeOptions());


        driver.findElement(By.cssSelector("#name")).sendKeys("Username");
        driver.findElement(By.cssSelector("#password")).sendKeys("Password");
        driver.findElement(By.cssSelector("#login")).click();

        boolean passed = driver.findElement(By.cssSelector("#logout")).isDisplayed();
        if (passed) {
            System.out.println("Test Passed");
        } else {
            System.out.println("Test Failed");
        }

        driver.quit();
    }
}