API UI Automation using Python Selenium Framework

Modified on Mon, 2 Dec at 6:59 PM

TABLE OF CONTENTS

1. Overview

2. Prerequisites

3. Leveraging algoQA, you can perform the following

3.1 Profile the application

3.2 Generate and Execute Scripts

1. Overview

API automation using the Python Selenium framework involves using Selenium WebDriver to automate the testing of APIs (Application Programming Interfaces). Selenium is primarily used for automating web browsers, but it can also be used for API UI testing.

2. Prerequisites

  • Install Python and Required Libraries:


    Download and install Python from the official website (Python.org).

    Install Selenium by running the following command:
    pip install selenium

  • Install the required packages by running the following commands:
    Package                    Version

    -------------------------- ---------

    allure-behave 2.13.2

    Appium-Python-Client 3.0.0

    behave 1.2.6

    numpy 1.26.0

    opencv-python 4.8.0.76

    Pillow 10.0.1

    pixelmatch 0.3.0

    PyYAML 6.0.1

    requests 2.31.0

    scikit-image 0.21.0

    scipy 1.11.2

    selenium 4.13.0

    webdriver-manager 4.0.1

    xmltodict                  0.13.0



  • View Installed Packages:
    After installing Python and the required libraries, you can use the pip list command to view a list of installed packages and verify that requests and selenium are included.

  • In addition, following components are required. Click only the required links corresponding to the components you need for installation procedure.

    algoQA , AlgoAF, Academy, algoScraper Extension, Database Access and Downloads  


3. Leveraging algoQA, you can perform the following

3.1 Profile the application

Profiling is the process of creating an offline model of an application under test (AUT), which involves mimicking a UI model of an AUT using nodes, features and UI elements.


Profiling involves: 

  • Create an Offline Model - To create an offline model, see Profiling article.

  • Recording the scenarios using FollowMe feature

    Follow Me feature is used to record and save the workflow or scenario or use case. Scenario will be saved in the same sequence it has been recorded.


Note: Recording for the FollowMe feature is done in an offline model. It doesn’t interact with the live application.


For more information, see Follow Me section in the Profiling article. 

  • Generating Test Cases
    Test cases are generated in Gherkin language and are Behavior-driven development (BDD) compliant.
    For more information, see Generate Test cases section in the Profiling article.

    Navigate to the test cases folder to view the system generated Feature File.

3.2 Generate and Execute Scripts

Perform the following:

  1. Navigate to the appropriate folder in the Script Generation screen. 
  2. Select the required files under Test Cases folder and click Analyze button. 


  3. In the pop-up window, click Proceed to highlight the Generate Script button.

  4. Click Generate Script. By default, page will revert to previous state after generating the scripts.

  5. Scripts are generated successfully with the specified report.  

  6. Download and Execute the script.

    • Download the script and save it to your local folder.
  7. Execute the script

    • Navigate to the same folder described in the previous step. Type 'cmd' Run the following command to trigger the script.
      Behave
    • Build success message will be displayed and you can view the respective report with the log messages  for Verification steps, as follows:




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article