Execute Scripts in Command Prompt or Terminal using Python Appium Framework

Modified on Fri, 19 Apr 2024 at 08:01 PM

Prerequisites

  • Setup for scripts execution on windows.
    This section guides on configuring the required prerequisite's. For more information, follow the steps described in Setting up an Android Emulator

  • Appium server must be running to run the scripts.

Executing the scripts


To run scripts on windows computer, the Command Prompt is utilized. Navigate to the folder where the Feature File is located, and open the command prompt from this location.


The script execution command must resemble the following example:

behave -f allure_behave.formatter:AllureFormatter -o D:\projects1\Mobile_App\Android\mmt\Python_APPium_Project133425488530054187\features\temp -f pretty "D:\projects1\Mobile_App\Android\mmt\Python_APPium_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).
-fallure_behave.formatter:AllureFormatter: 
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.
-o D:\projects1\Mobile_App\Android\mmt
\Python_APPium_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\Mobile_App\Android\mmt
\Python_APPium_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.



Alternatively, if the report isn't generated despite executing the previous commands, then perform the following to generate reports using Mono packages:

  1. Download the Mono package from the official website: Mono-project.com.
  2. Install the Mono package on your system.
  3. To verify the installed Mono version, open the command line interface (CLI) and execute the following command:
    mono --version

    This command will display the installed Mono version, allowing you to ensure that the correct version is installed on your system for generating the report.

Note: If you are running the script on an iOS device to generate reports, open a terminal and run the commands specified previously, replacing 'Command Prompt' with 'Terminal'.





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 atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article