Selcukes Documentation

website·Indexed 29 days ago

https://selcukes.github.io/docs

An open-source automation solution and testing library for Web, Desktop, Mobile, and API endpoints. Features include DataBind for parsing JSON, YML, XML, and CSV; ExcelMapper for .xlsx files; a Video Recorder for tests; and integration with TestNG, Extent Reports, and Selenoid Grid.

Tokens
12.8K
Snippets
76
Records
89
Agent score
75%

What's inside Selcukes

  1. Overview of WebDriver Binaries

    WebDriver Binaries is an open-source Java library designed to automate the management of binary drivers (e.g., chromedriver, geckodriver, msedgedriver) required by Selenium WebDriver. It handles the platform-specific download of the correct driver version based on the installed browser, configures the necessary Java system properties, and manages a local cache to ensure compatibility and performance.
  2. Overview of the Selcukes automation framework

    Selcukes is an open-source, all-in-one automation solution used to test Web, Desktop, Mobile, and API services. It provides a unified Framework API, meaning the same syntax is used across all supported platforms, allowing developers to apply their web testing knowledge to mobile, desktop, and API testing immediately. Key features include automatic waiting (eliminating the need for manual sleeps or waits) and readable error stack traces for faster debugging.
  3. Overview of Selcukes testing library

    Selcukes is an open-source testing library designed for creating scalable automated tests across web, mobile, desktop applications, and API endpoints. Key capabilities include:

    • Adding new test logic without causing regressions
    • Full control over execution workflows (including browser reuse and changes)
    • Automatic retry of failing tests
    • UI automation on emulators and real devices
    • Cross-platform screenshot and video recording upon test failure for debugging
  4. Create category cards for overview pages

    For overview pages with four categories, use the box-wrapper and card HTML structure. Note that Markdown is not supported inside these HTML blocks; use standard HTML tags for formatting.
    <div className="box-wrapper" markdown="1">
        <div className="box box1 card">
            <div className="container">
                <h2>Box 1</h2>
                <p>Box 1 things.</p>
                <ul>
                    <li><a href="">Link 1</a></li>
                    <li><a href="">Link 2</a></li>
                </ul>
            </div>
        </div>
        <!-- Repeat for box2, box3, box4 -->
    </div>
  5. Handle CsvMapper parsing and writing errors

    When using CsvMapper for parsing or writing files, be prepared to handle DataMapperException. This exception is thrown when an error occurs during file processing and contains details about the failure and the underlying cause.
  6. Reference GitHub code using version tags

    To prevent code examples from becoming stale, reference code from demo-<language> repositories using semantic version tags (e.g., docs-1.0) instead of branch names or commit hashes. This is achieved via a custom Docusaurus plugin.
    git tag -a -m 'reference for Selcukes documentation' docs-<version>
    git push origin --tags
  7. Parse Excel sheets into entity class objects

    Use ExcelMapper.parse(Class<T> entityClass) to convert an Excel sheet into a stream of Java objects.

    Mapping is configured via annotations on the entity class:

    • @DataFile: Specifies the fileName and sheetName. If fileName is omitted, it defaults to the SnakeCase of the class name with a .xlsx suffix. If sheetName is omitted, the first sheet is used.
    • @Key: Maps a class field to a specific Excel column name using the name attribute. It also supports a format attribute for date parsing (e.g., MM-dd-yyyy).
    public class ReadExcelTest {
        @Data
        @DataFile(fileName = "TestData.xlsx", sheetName = "Yahoo")
        static class TestData {
            @Key(name = "First Name")
            String firstName;
            @Key(name = "Last Name")
            String lastName;
            @Key(name = "DOB", format = "MM-dd-yyyy")
            LocalDate dob;
            String location;
        }
    
        @Test
        public void excelMapperTest() {
            Stream<TestData> dataStream = ExcelMapper.parse(TestData.class);
            dataStream.forEach(System.out::println);
        }
    }
  8. Substitute Excel values using custom interpolators

    Use the @Interpolate annotation on an entity class to substitute field values (e.g., ${DATE}) during parsing. To use a custom substitution logic, extend DefaultSubstitutor and override the replace(String strToReplace, String format) method, then specify the class in the @Interpolate annotation.
    public class FakerDataSubstitutor extends DefaultSubstitutor {
        @Override
        public String replace(String strToReplace, final String format) {
            return FakerUtils.substitute(strToReplace);
        }
    }
    
    // Usage in Entity
    @Interpolate(substitutor = FakerDataSubstitutor.class)
    @Data
    @DataFile(fileName = "TestData.xlsx")
    static class TestData {
        @Key(name = "First Name")
        String firstName;
    }
  9. Parse a CSV file into a DataTable using CsvMapper

    Use the CsvMapper.parse() method to read a CSV file from a given Path and convert it into a DataTable<String, String>. You can use the default regex for parsing or provide a custom regex to handle specific CSV formats.
    // Method 1: Using Default Regex
    Path filePath = Paths.get("path/to/your/file.csv");
    DataTable<String, String> dataTable = CsvMapper.parse(filePath);
    
    // Method 2: Using Custom Regex
    Path filePath = Paths.get("path/to/file.csv");
    DataTable<String, String> dataTable = CsvMapper.parse(filePath, CsvMapper.CSV_REGEX);
  10. Understand the WebDriver binary resolution algorithm

    When setup() is called, WebDriver Binaries performs the following steps:

    1. Browser Version Discovery: Uses a internal database of shell commands (e.g., google-chrome --version) to find the installed browser version.
    2. Driver Version Mapping: Identifies the compatible driver version based on the browser version using maintainer-provided resources.
    3. Download & Cache: Downloads the binary to a local cache (default: %temp%/webdrivers).
    4. System Property Export: Sets the corresponding Java system property (e.g., webdriver.chrome.driver) to the path of the downloaded binary.

    To optimize performance, a resolution cache (version.properties) is used with a default Time-To-Live (TTL) of 1 hour, reducing the need for repeated shell commands or external network requests.