Executing scripts via Command PromptExecute Scripts in Command Prompt or Terminal using Python Appium Framework

Execute Scripts in Command Prompt or Terminal using Python Appium Framework

Execute Python Appium test scripts on Windows or macOS using the Command Prompt or Terminal, with Allure report generation.

Prerequisites

Set up script execution on Windows. This section guides on configuring the required prerequisites. 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 a Windows computer, use the Command Prompt. 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 instructs 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. This command is added in the readme file and can be used to generate Allure reports. Use the following command:

allure generate --single-file <json_file_path> -o <output_path>

The following table represents command-line arguments:

KeyDescription
behaveThis is the command to run Behave, which is a popular Python testing library for behavior-driven development (BDD).
*-allure_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\tempThis 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:

Download the Mono package

Download the Mono package from the official website: Mono-project.com.

Install the Mono package on your system.

Follow the on-screen instructions in the installer to complete the installation.

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.

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'.