ScriptlessAutomation
  • 👋Welcome to Scriptless Automation
  • Discover More About Automation
    • ⚙️Automation platform intro
    • 💡Advantages of Scriptless Automation
    • 🚀Release Notes
      • 📖Open Code
      • 📕License Code
  • Product tools
    • 📪Pre-request Tools
    • 🔧Project Dependencies
  • Automation Architecture
    • 🎨Flow diagram
  • Get Started
    • 🛠️Start with Automation
    • 📖Open Code Automation
      • 🌏Web Automation
      • ↔️API Automation
    • 🏢Maven Configuration
    • 🗜️Setting Up Maven Project in IntelliJ IDEA
    • 🎛️Scriptless Config
      • 🕸️BrowserConfiguration
        • chrome.properties
      • 👥CommunicationConfiguration
        • SlackConfiguration.properties
      • 📧MailConfiguration
        • gmailCredentials.properties
      • 🛂ReportConfiguration
        • extentReportConfiguration.properties
      • 🕵️TestManagementConfiguration
        • testRail.properties
        • zephyrscale.properties
        • testiny.properties
      • ⚙️testNgConfiguration.properties
    • 🍱TestData Configuration
    • 👨‍💼Gherkin Language and Scriptless Automation Framework
  • Automation Import Notes
    • 🎨Points to Remember
  • Automation Platforms
    • 👾ScriptlessApi Automation
      • 🖊️Introduction
      • 🗜️Api Automation Setup
      • 🔃Supported API Request Types
      • 🪧API Automation Template
      • 📚Example of API Requests
        • ⬇️GET
        • ↕️POST
        • ⤵️PUT
        • ❌DELETE
      • 🎯API Response Validation
      • 👨‍👦API Dependent TestCase
      • 📝Store API Variables
      • 📔API with JSON body
      • 🙋‍♂️Api Wait
      • 🗜️API Schema Validation
      • 🏗️API Tailor-Made coding
      • 👨‍🦯API Support Generator
      • ↘️Api Response Store Objects
      • ✍️API Test Report
      • 🚃Api Response Type Validation
    • 🌐ScriptlessWeb Automation
      • 🖊️Introduction
      • 🗜️Web Automation Setup
      • 🪧Web Automation Template
      • 🧮page_object_locators
      • 📜Web Automation Key Phrases
        • 📃PAGE_NAME
        • ⌛WAIT_TYPE
        • 📜SCROLL_TYPE
        • 👨‍💼ELEMENT_NAME
        • 🏎️ACTIONS
        • ⌨️SEND_KEYS
        • ✔️VALIDATION
        • ✅VALIDATION_TYPE
      • 👨‍👦Web Dependent Test Case
      • 🐒MOCK
      • 🛂AutomationAsserts
      • 🏗️Web Tailor-Made coding
      • 📝Store Web Variables
      • 🤼‍♀️Web & API integration
      • 🖇️Dynamic Strings
      • 🗣️ReadFile Annotation for Custom Code
      • 🖼️Page_Comparison
      • 👨‍💼Gherkin Template for Web Automation
    • 📱Mobile Automation
  • 🪶Automation features
    • 🌲Environment and System Variables
    • 🗝️KeyInitializers
      • Types of KeyInitializers
    • ✍️Reporting
      • Dashboard
      • Category
      • Tests
        • Screenshot Section
    • 👯Parallel Testing
    • 🏗️Tailor-Made Coding
  • ⏩Automation Demo
Powered by GitBook
On this page
  • Overview
  • Annotation Parameters
  • Supported File Types
  • Applying @ReadFile to Custom Code
  • Example Usage
  • Conclusion

Was this helpful?

  1. Automation Platforms
  2. ScriptlessWeb Automation

ReadFile Annotation for Custom Code

The ReadFile annotation is an integral part of the Precision Test Automation framework, crafted exclusively for enhancing file handling capabilities within custom code sections. This annotation is tailored to specify file reading parameters for methods that are explicitly designed to interact with files — such as downloading or reading from a specified path — as part of the automation of web applications, especially when involving file downloads through WebDriver.

Overview

Designed for use exclusively within the framework's custom code feature, @ReadFile allows developers to declaratively specify how and which files should be interacted with in their custom code methods. This approach facilitates streamlined file manipulation tasks, ensuring a more organized and maintainable codebase.

Annotation Parameters

directoryPath

  • Type: String

  • Default: "" (empty string)

  • Description: The filesystem path to the directory from where the file should be accessed. If unspecified, a default directory may be assumed based on the context of the custom code.

fileNameStartsWith

  • Type: String

  • Default: "" (empty string)

  • Description: A filter applying to file names, targeting files that begin with the specified prefix. This parameter aids in narrowing down the files to be processed by the custom code.

fileType

  • Type: FileTypes

  • Required: Yes

  • Description: The type of file the custom code method will handle. It must be one of the predefined FileTypes enum values, guiding the method in processing the correct file format.

timeOut

  • Type: int

  • Default: 10

  • Description: The maximum duration, in seconds, the custom code will wait for a file download to complete when initiated through ChromeDriver. This parameter is crucial for ensuring that the method does not proceed before the file is fully downloaded.

Supported File Types

The framework currently supports two file types:

  • CSV: Used for files containing comma-separated values, ideal for data-driven testing scenarios.

  • TXT: Plain text files, often used for configuration or data that does not require a specific structure.

Applying @ReadFile to Custom Code

The annotation is intended for use with methods that perform file operations, such as reading from files or managing file downloads, enhancing the efficiency and reliability of tests involving file operations.

Example Usage

CSV File Interaction

javaCopy code@ReadFile(
    directoryPath = "test_data/web/test_case_flows/testdirectory",
    fileNameStartsWith = "KeyBoardDown_Sanity",
    fileType = FileTypes.CSV
)
public void getCsvFile(Hashtable<String, List<String>> table, Set<String> set){
    // Custom code to handle CSV file
}

In this example, the getCsvFile method is configured to interact with CSV files in the specified directory that begin with "KeyBoardDown_Sanity".

TXT File Interaction

javaCopy code@ReadFile(
    directoryPath = "test_data/web/page_object_locators",
    fileNameStartsWith = "sample",
    fileType = FileTypes.TXT
)
public void getTxtFile(List<String> table){
    // Custom code to handle TXT file
}

Here, the getTxtFile method is set up to read TXT files starting with "sample" from a specific directory path.

Conclusion

The ReadFile annotation significantly enhances file operation integration within the custom code sections of automation scripts. By clearly defining file interaction parameters, it improves code readability, maintainability, and project reliability, particularly in test automation frameworks where file handling is a routine task.

PreviousDynamic StringsNextPage_Comparison

Last updated 1 year ago

Was this helpful?

🌐
🗣️