Integration is an unsung hero.  It is often one of the main secrets to a well-run business, but it doesn't get much attention. Integration in English means "combining the efforts of people to work together". In the corporate world, two organizations will often come together to work towards a single goal. For example, Samsung Integrated with Instagram to provide a dedicated section for the app on their new smartphones. Similarly, within an organization, different roles like a tester, a developer, and a manager all integrate to deliver software through their combined efforts. TestProject is key to supporting this integrated effort. TestProject integrates directly with other solutions teams already feel comfortable working with, making work easier for everyone. In this post, we will take you on a tour of TestProject's OpenSDK / TestProject SDK and using it along with TestProject to run code from the system integrated with TestProject's environment.

  • What is TestProject's OpenSDK?
    • What does the OpenSDK signify in TestProject?
    • How to Download and Install the OpenSDK fro TestProject?
  • How to write a test using TestProject's Python OpenSDK?

What is TestProject's OpenSDK?

A software development kit (SDK), as the name suggests, is an all-in-one package of the required elements for running any given software. An SDK is installable so that it can be used on the personal system, typically via an IDE. An SDK typically contains all of the tools required, including a compiler, debugger, framework, etc. When an SDK installs onto a local system, it works smoothly with the operating system.  This combination of tools and the operating system helps testers and developers perform their duties with ease. In TestProject, we will achieve the same by creating and running the test code.  First, we need to download and install TestProject's OpenSDK on our system.

What does the OpenSDK signify in TestProject?

TestProject provides their user with the OpenSDK in the three most popular languages around the globe.  The OpenSDK uses a familiar syntax, as its built is on top of Selenium and Appium. Because TestProject refrains from the practice of providing their proprietary commands in their SDK, all of their commands inherit from Selenium and Appium. Therefore, if you have ever worked in Selenium and Appium or are familiar with it, using TestProject's SDK is a piece of cake. TestProject's SDK allows us to create tests that leverage the TestProject reports for automated analysis, as we will see later into the chapter. Using TestProject SDKs also helps you take advantage of TestProject's Agents and configure our tests accordingly.

TestProject  provides SDKs in the following languages:

  • Java
  • C#
  • Python

TestProject is also working to develop SDKs in other programming languages (such as JavaScript) to serve the largest testing community possible and make your job as easy as possible. In the next section, we will outline the procedure to download and install the OpenSDK on our systems to build a perfect environment for running our test cases.

How to Download and Install the OpenSDK for, TestProject?

Downloading and installing the SDK in TestProject is a very straightforward task. To download, visit the TestProject Dashboard at "https://testproject.io/ " and login into your account, then follow the steps as mentioned below:

  1. Hover to the Integrations tab  after you log in: Integration with TestProject SDK

  2. Select the SDK  you want to download from the list: Various SDK provided by TestProject

Note: We will be using Python SDK for this tutorial, but if you feel more comfortable coding in another language, feel free to go ahead with the language of your choice from the list.

  1. The screen will show you the command to install the Python SDK: pip_install_testproject

  2. We will go ahead with the pip install since it is easy, and the location should never change for the updated version. There are multiple options for the installation, though. These are:

  • Using PiP: pip will help install the SDK easily and without any extra work. We will use this option.
  • PyPI Package: The PyPi package can also install the SDK.  The user can navigate from the same page where the pip command is there (outlined in the above screenshot).
  • PiP Env: The pip env smoothens out the issues by creating the virtual environment and works with "pip" under the hood.

If you like the PyPI package or pipenv, you can go ahead to the link given and install this as a PyPI package similar to any other software.

  1. Go to the shell of your system and type the command as mentioned above to install the Python SDK for TestProject: install_sdk_through_shell

Note: This requires that the system should equip with Python and Pip. Otherwise, the command won't execute. Refer to our Python tutorial to understand how to install Python and Pip.

  1. Execute the command, and the OpenSDK will install smoothly.

Now that we finish creating the environment we need, we will run some tests on our system and see how it integrates with our TestProject account.

How to write a test using TestProject's  Python OpenSDK?

You may recall that we discussed how TestProject's OpenSDK gives you the freedom of writing the tests in the same logic as you would with Selenium or Appium. Therefore, we can add just two lines of code, and then we can write our test cases based on Selenium.

Use any of the Python's IDE and paste the following code in a python file, say testproject.py:

from src.testproject.sdk.drivers import webdriver 

def test_login_to_testproject_example_app(): 
	driver = webdriver.Chrome(projectname='My custom project For sdk', token = "yourtoken") 
	driver.get('https://example.testproject.io/web/') 
	driver.find_element_by_id('name').send_keys('John Smith') 
	driver.find_element_by_id('password').send_keys('12345') 
	driver.find_element_by_id('login').click() 
	assert (driver.find_element_by_id('greetings').is_displayed() is True), driver.quit() 


if __name__ == "__main__":
    test_login_to_testproject_example_app()

Where,

  • from src.testproject.sdk.drivers import webdriver: This import line is similar to Selenium's import line, and it makes the TestProject specific webdriver available to the test script.
  • driver = webdriver.Chrome(token = "yourtoken"): This is similar to the Selenium web driver's initialization. We are initializing the webdriver instance using chrome. The extra parameter in the case of the Testproject is the user's unique "token", which is passed as a 2nd parameter while initializing the object of the webdriver.

So, what is this token? And, can we run our tests without it? Let's see. Try removing the parameters from the second line (your token) and check if the test still works. Run the test script using the following command in the directory where we save the python file:

python testproject.py

The output will look like, showing a failure: run_without_token

Okay, so now we know that the token referenced is our TestProject Developer Token, and it is an essential aspect of connecting your coded tests to your account in TestProject's Dashboard.

The developer token passed in a while initializing the driver attaches your tests to your TestProject account so that you have your reports available in TestProject's dashboard. The developer token is unique for each user, and one should not share it with anyone. You can access your developer token on the same page from where we downloaded the SDK.

Head back to the same page (https://app.testproject.io/#/integrations/sdk) and check out your token, which can easily copy to the clipboard. developer_token

Paste this in place of "your_token*" in the above code and rerun the python file.

Now, the process is complete!  We have developed and run our first test case in TestProject's Python OpenSDK, closely based on Selenium. You can now head on to the Reports tab available at the header navigation bar: reports_tab

The reports of your tests will be available here that you just executed from your system: SDk Project Report in TestProject

If you want to learn more about TestProject's reports, a detailed post awaits you on our platform.

As you can see, not much work was required to create and test cases using the TestProject OpenSDK. It was a straightforward task, with the most challenging work being downloading and installing the SDK. To summarize, the next section will give you some key takeaways.

Similar to TestProject's Python's OpenSDK, you can download the JAVA or C# OpenSDK, depending on which language you prefer. TestProject's OpenSDK can kickstart the journey of writing automated test cases using TestProject for both Web and Mobile applications.

Key Takeaways

  • TestProject provides its OpenSDK to integrate your coded test cases with your TestProject environment seamlessly.
  • TestProject provides its OpenSDK in three popular languages: Java, C#, and Python (with JavaScript coming soon).
  • TestProject's OpenSDK wraps around Selenium and Appium, so you should find the logic and syntax remains the same (with minor changes to your existing tests).
  • Running a test case with TestProject's OpenSDK requires a developer token, which is unique to each user and available in the TestProject Dashboard.
  • After running a test case with TestProject's SDK, the reports from the executed tests will show up automatically in the TestProject reports area of the dashboard.
Writing your first mobile test in TestProject
Writing your first mobile test in TestProject
Previous Article
TestProject Addons
TestProject Addons
Next Article
Harish Rajora
I am a computer science engineer. I love to keep growing as the technological world grows. I feel there is no powerful tool than a computer to change the world in any way. Apart from my field of study, I like reading books a lot and developing new stuff.
Reviewers
Lakshay Sharma's Photo
Lakshay Sharma

Similar Articles

Feedback