Welcome to Arjuna - The Framework for Professional Coded Testing¶

Arjuna is a Python based test automation framework developed by Rahul Verma.
It is an open source, Apache Licensed software: Arjuna on GitHub.
Rahul has implemented smaller variants of features in Arjuna across frameworks and organizations, or given advice around it. However Arjuna being a generic library has the most complete implementation of his ideas, away from project specific contexts and constraints.
For test execution, Arjuna is implemented as a pytest plugin and provides its own markup over pytest as its underlying test engine. If you like, you can make use of Arjuna with any other test engine or custom frameworks as well.
You’d need Python 3.8+ to make use of Arjuna.
Note: On Linux, the built-in Python3 build has issues with the Python’s built-in enum module which is heavily used in Arjuna. One alternative is to install ActiveState Python on linux. Advanced users can go for installing a custom Python build.
You can find a lot of example code for using Arjuna in Arjex project on GitHub.
Tester’s Guide¶
Arjuna Fundamentals¶
- Installing Arjuna
- Arjuna Test Project
- Basics of Writing Automated Tests in Arjuna
- Provisions in @test Decorator
- Arjuna’s Command Line Interface as pytest plugin
- Handling Test Resources
- Handling Configuration Options
- Understanding Configuration System of Arjuna
- project.yaml - Setting Project Level Configuration Options
- Configuration Builder - Creating Custom Configurations
- Defining and Handling User Options
- Configuration Builder - Adding options from a .yaml File
- The Magic C Function
- Data Configurations and Environment Configurations
- Arjuna Options Reference for Overriding
- Test Selection Rules
- Logging
- Introduction
- Arjuna’s Logging Functions to Support Python Logging Levels
- Controlling Which Log Messages Are Included on Console and in Log File
- Default Logging Levels
- Arjuna’s TRACE Log Level
- Overriding Logging Level Defaults
- Contextual Logging
- Auto-Logging using @track Decorator
- Tracking Methods, Functions, Properties
- Tracking All Methods in a Class
- Default Logging Level for @track
- Changing Logging Level for @track
- Test Reporting
Handling Data and Information Exchange Formats¶
- Data Driven Testing with Arjuna
- Purpose
- Single Data Record
- Multiple Data Records
- Driving with Static Data Function
- Driving with Static Data Generator
- Driving with Dynamic Data Function or Generator
- Driving with Static Data Classes
- Driving with Dynamic Data Classes
- Driving with Data Files
- Driving with Excel File
- Driving with Delimited Text File
- Driving with INI File
- Data Files with Exclude Filter for Records
- Driving with Multiple Data Sources
- Data Spaces - Shareable Data Objects for Tests
- Data References
- Random Data Generation
- Data Entities
- Creating a Basic Data Entity
- Setting Defaults in Data Entity
- Data Entity has a Python Dictionary-like Behavior
- Creating Immutable Data Entity Objects
- Basic Usage of Random with Data Entity
- Dynamic Generation of Data for Data Entities
- Processing Dynamically Generated Data
- Defining Composite Data Using composite and composer Constructs
- Creating a Data Entity from Other Data Entities
- Defining Entities for Dependency Injection
- Built-in Complex Random Data Entities
- Handling Information Exchange Formats
- Text
- JSON (Javascript Object Notation)
- Creating JSON Objects
- Json Class Assertions
- Automatic Json Schema Extraction
- JsonDict Object
- Finding Json elements in a JsonDict Object
- Matching Schema of a JsonDict Object
- Asserting JsonDict Object
- JsonList Object
- == Operator with JsonDict and JsonList Objects
- Size Related Assertions in JsonDict and JsonList Objects
- Modifying JsonSchema Object
- YAML
- XML
- XmlNode
- Creating an XmlNode Object
- Inquiring an XmlNode Object
- Cloning an XmlNode Object
- Finding XmlNodes in an XmlNode Object using XPath
- Finding XmlNodes in an XmlNode Object using XML.node_locator
- Providing Alternative NodeLocators (OR Relationship)
- Exiting XmlNode.findall on First Matched Locator
- HTML
- Data Localisation
Web GUI Automation¶
- The GuiApp class
- Element Identification
- Element Interactions
- Element State Checking and Dynamic Waiting
- Inquiring Element Information
- Gui Namespace - Externalizing Locators
- Basic GuiWidget Locators
- Arjuna’s Locator Extensions
- Arjuna Advanced Locators: Node Definition Based Locators
- Arjuna Advanced Locators: Axes Locator
- Alternative Locators - Specifying Multiple Locators with OR Relationship
- Dynamic/Formatted GuiWidget Locators
- Visual Relationships for Selection of GuiElements
- Selection-Time Positional Filtering
- Defining Your Own Locators using withx
- Advanced Gui Abstractions
- Advanced GuiWidgets: GuiMultiElement - Handling Multiple GuiElements Together
- Advanced GuiWidgets: DropDown - Handling Default HTML Select
- Advanced GuiWidgets: RadioGroup - Handling Default HTML Radio Group
- Handling Frames
HTTP Automation¶
- Introduction
- SEAMful Model for HTTP Layer Automation (In-Progress)
- Implementation 1 - Using Anonymous Service (Completed)
- Implementation 2 - Using Anonymous Service and Messages (In Progress)
- Implementation 3 - Using Anonymous Service, Actions and Messages (In Progress)
- Implementation 4 - Using Named Services and Messages (In Progress)
- Implementation 5 - Using Named Services, Actions and Messages (In Progress)
- Implementation 6 - Using Named Services, Endpoints, Actions and Messages (Future)
- SEAMful: Service
- Creating an HTTP Service
- Supported HTTP Methods in Arjuna
- Basic GET Example
- HTTP Response
- Customizing HTTP Requests
- Customizing HTTP Requests
- Handling Content Types in POST/PUT/PATCH Requests
- Setting a Request Label
- Setting Arbitrary Query String Parmaters in URL
- Analyzing HTTP Response
- Checking Expected HTTP Status Code(s)
- The HttpResponse Object
- SEAMful - Message
- Introduction
- Defining Messages with Anonymous Service
- Defining Messages with Named Service
- Sending Message using Service
- Blank Message File
- GET is default method
- Checking Response Codes
- Specifying Request Label
- Sending Arbitrary Key-Values in Query String
- Dynamic Messages using Arjuna’s $<name>$ Placeholders
- Handling Content Type
- Adding HTTP Headers
- Validating Headers in Response
- Validating Cookies in Response
- Content Validation - Check Presence Using has Construct
- Content Validation - Check Equality Using match Construct
- Extracting and Storing Data From Response - store Construct
- Custom Validations on Extracted and Stored Data in a Message
- Optional Extractions
- SEAMful - Action
- Introduction
- Defining Actions with Anonymous Service
- Defining Actions with Named Service
- Sending Action using Service
- Performing Sequence of HTTP Messages without HTTP Action Abstraction
- Basic HTTP Action File
- Performing HTTP Action
- Using Flattened Dictionary for Data
- Using Flattened Data Entity for Data
- Using Data Defined in Action File
- Creating and Using Data Entity in Action File
- Creating Aliases for Data
- Extracting and Using Data From One Message to Another
- Support for Open Authentication (OAuth)
Email Automation¶
- Emails in the Context of Test Automation
- Automating Email Reading
- Connecting to Email Server
- Default Configuration Settings in Arjuna for Email Server
- Project-Level Default Configuration for Email Server
- Accessing a Mailbox from Server
- Reading Latest Emails
- Reading Oldest Emails
- Reading Email at an ordinal
- Filtering Emails
- Filtering Emails by Sender
- Filtering Emails by Subject
- Filtering Emails by Content
- Reading New Emails - The Challenges
- Reading New Emails - One Time
- Reading New Emails - Multiple Times
- Processing Emails
- Inquire Email Meta-Data
- Get Email Contents
- Extracting Links from the Email
Security Testing¶
- Simple Built-in HTTP Layer Security Tests for GET Requests
- Introduction
- Auto-complete Should be Disabled
- Private Resource Disclosure
- Private IP Disclosure
- Cross-Origin Resource Sharing (CORS)
- Frameable Response (Potential Clickjacking)
- Strict Transport Policy
- Information Disclosure
- Minium Secure JS Version
- Vulnerable JS Version
- Cookie - HttpOnly Flag
- Cookie - secure Flag
- Malicious URL Redirect
Notes About Python Libraries and Tools Used in Arjuna¶
Frequently Asked Questions (FAQs)¶
Tester Programming Interface (TPI) Reference¶
All classes, functions, enums and exceptions that are supposed to be directly used by a test author are a part of Arjuna’s Tester Programming Interface (TPI).
This interface is fully encapsulated in arjuna.tpi
package.
You can either do a fully qualified import for a public name, for example:
from arjuna.tpi.log import log_info
or an easy, simple import that imports all public TPI names from Arjuna:
from arjuna import *
Following links direct you to documentation for all public names:
Test, Test Resources and Assertions¶
Test Configuration¶
The Magic Functions¶
Data Driven Testing¶
Data Source Markup
Data Generation and Data Entities¶
Data References¶
Web GUI Automation¶
Gui
: It represents all type of Guis and is the base class for the following classes:GuiAppContent
: It represents the content of a GuiApp and is the base class of the following classes:
- Defining and formatting Gui Widget Locators:
- Classes related to formatting of GuiWidgetDefinition:
- Different Gui Widgets
GuiMultiElement
Filtering a GuiMultiElement -
GuiMultiElementFilter
- Inquiring Gui Source
GuiSourceContent
- Encapsulates source content for all Guis and GuiWidgets.
HTTP Automation¶
HttpService
- OAuth Support
E-Mail Automation¶
Reporting Protocols¶
Objects In Arjuna Hooks¶
Parsers¶
Helpers¶
Logging¶
Arjuna Exceptions¶
Indices and tables¶
Contributors¶
This package is authored and maintained by:
with the help of patches submitted by these contributors.
Copyright and License¶
Copyright 2015-2021 Rahul Verma
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.