Setting Up and Executing Selenium Scripts in Command Prompt Using Python

Modified on Thu, 8 Aug at 12:53 PM

TABLE OF CONTENTS

1. Prerequisites

2. Executing Selenium Scripts in Command Prompt on Windows Operating System

1. Prerequisites

To configure Python and Selenium, refer to the article  Configuring Web Applications Using Python Selenium Framework.


2. Executing Selenium Scripts in Command Prompt on Windows Operating System

Perform the following: 

  1. Download and extract the script to your local folder.  Navigate to the same folder.
  2. In the folder navigation bar, type 'cmd ' and press 'Enter' to view the Command Prompt screen.
  3. Run the following command to schedule and execute the script.The script execution command must resemble the following example:  
    behave -f allure_behave.formatter:AllureFormatter -o D:\projects1\Web_App\Application\mmt\Python_Selenium_Project133425488530054187\features\temp -f pretty D:\projects1\Web_App\Application\mmt\Python_Selenium_Project133425488530054187\features" --tags=@test001 
    

    The previous command is instructing Behave to run tests from the specified Feature File, generate Allure reports, and include only scenarios with the @test001 tag. The temporary Allure report files will be stored in the specified output directory.

    The following table represents command-line arguments:

    KeyDescription
    behave
    This is the command to run Behave, which is a popular Python testing library for behavior-driven development (BDD).
    -f allure_behave.formatter:AllureFormatter -o
    This part of the command specifies the formatter to be used for the output. In this case, it's the AllureFormatter, which is used to generate reports in the Allure format. Allure is a flexible and extensible test reporting framework.
    D:\projects1\Web_App\Android\mmt
    \Python_Selenium_Project133425488530054187\features\temp
    This flag specifies the output directory where the Allure report files will be generated. In this case, it's set to a temporary directory.
    -f pretty:This flag specifies that the output must also be in a human-readable format (pretty format).
    "D:\projects1\Web_App\Android\mmt
    \Python_Selenium_Project133425488530054187\features"
    This is the path to the directory where your Behave Feature File is located. Behave will look for feature files in this directory.
    --tags=@test001This flag filters the execution of scenarios based on the specified tags. In this case, it's set to run scenarios with the tag @test001. Tags in Behave are used to categorize and filter scenarios.


  4. You can view the respective report.



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