Gwen Gherkin Interpreter
website·Indexed 32 days ago
https://gweninterpreter.org/docsA Gherkin interpreter with built-in web automation that executes plain-English feature specifications in a real browser.
What's inside Gwen
- Gwen is a Gherkin interpreter with built-in web automation. It enables developers to write plain-English feature specifications which Gwen then executes in a real browser using its built-in DSL, eliminating the need for traditional glue code.
Gwen Project Setup and Execution
To get started with Gwen, users can follow the setup guide to install the software, initialize a project, and run sample features. Execution can be managed via the Command-line launcher, which supports specifying meta files, profiles, and batch mode. For interactive debugging and on-the-fly execution, Gwen provides a REPL console. Additionally, a 'Dry Run' mode is available to validate specifications without performing actual browser actions.Implement loops and conditionals in Gwen DSL
Gwen provides several control-structure keywords to manage execution flow within feature specs:
ForEach: Used to iterate over elements, records, or arrays.Until/While: Used to loop based on conditions, such as element states or file existence.If: Used for conditional execution based on element states, files, or other conditions.
Deploy and integrate Gwen with CI/CD and Cloud Grids
Gwen can be integrated into various deployment environments:
- Containers: Use Docker for consistent CI/CD environments.
- CI Tools: Integrate with Jenkins using generated Jenkinsfiles and Docker pipelines.
- Cloud Grids: Run tests on BrowserStack (via remote capabilities config) or LambdaTest HyperExecute (via YAML settings).
- Driver Management: Gwen uses SeleniumManager for automatic driver handling, though manual setup options are available.
Manage Step Definitions with Meta Specs and Annotations
Meta specs in Gwen define the step definitions and bindings that drive the execution of feature files. These specs utilize annotation tags (such as@StepDefand@Import) to organize and map Gherkin steps to automation logic.Configure Gwen via Settings and Profiles
Gwen's behavior, browser settings, and environment rules are managed through configuration options. These can be defined ingwen.conf, JSON, or properties files. Profile settings allow users to group specific launch parameters for different environments, such as 'samples' or 'CI'.Capture Data using Gwen DSL Capture
Gwen provides a suite of capture methods to extract information from the browser or external sources and bind them to variables:
- Text/Regex/XPath/JSON: Capture content from elements or bindings using specific patterns or paths.
- URL/Dropdown: Capture the current browser URL or the selected value of a dropdown.
- Screenshots: Capture the full page or a specific web element as an image.
- PDF/Base64: Extract text from PDFs (URL, file, or blob) or decode Base64 strings.
- Data Lookups: Retrieve values from CSV or JSON files using predicates.
Configure Gwen test reporting and artifacts
Gwen supports multiple report formats and visual artifacts to track test execution:
- Textual/Structured Reports: HTML (detailed feature view), Console (logs and stats), CSV (configurable results), JUnit XML (for CI/Jenkins integration), and JSON (for custom formatters).
- Visual Artifacts: Screenshots (captured on step execution), Slideshows (HTML playback of screenshots), and Video Recordings (MP4 capture available in Docker environments).
Validate State with Gwen DSL Assertions
Gwen provides specialized assertions to verify the state of the application:
- Content Asserts: Validate text, XML (XPath), and JSON (JSONPath) content.
- Browser State: Assert page titles, current URLs, and the number of open tabs/windows.
- Element/Dropdown: Verify element states, text values, and dropdown selections.
- File/Data: Check for file existence, emptiness, and uniqueness of values within CSV/JSON files.
- Logic: Use existential asserts to check if a binding is defined and cumulative asserts to handle soft assertion errors.
Use advanced Gwen DSL features for complex automation
Gwen includes several advanced capabilities for enhancing test scripts:
- Data Handling: Use
Data Feedsfor external data sources,Data Tablesfor tabular input, andDoc Stringsfor multi-line text. - Dynamic Values: Use
String Interpolationfor external properties andImplicit Valuesfor automatic value resolution. - Custom Logic: Bind JavaScript arrow functions as custom actions using
JS Functions. - Execution Control: Use
@Tryto ignore step failures,@Finallyto ensure steps run regardless of prior failures, and@Eager/@Lazyto control binding evaluation timing. - Element Interaction: Use
Locator Chainingto find elements inside frames/other elements,@Timeoutto override default wait periods on locators, andContext Sensitive Actionsfor elements visible only after hovering. - Environment & State: Use
Named Browser Sessionsto switch between multiple sessions,Template Matchingfor content verification/capture, andState Levels(e.g., present, absent) for assertions. - Performance & Device: Support for
Parallel Executionof scenarios andMobile Emulationfor Chrome/Edge via device names or custom metrics.
- Data Handling: Use
Use Gwen DSL Bindings to Map Data
Gwen's DSL provides various binding categories to associate names with data sources for use in tests:
- Text Bindings: Literal values (text, blank, empty, true, false).
- File Bindings: Binds names to file contents with optional encoding.
- Regex Bindings: Captures text from a source using regular expressions.
- XML Bindings: Extracts data via XPath (text, node, or nodeset).
- JSON Bindings: Uses JSONPath to bind data (supports eager, lazy, and masked options).
- JS Bindings: Defines names using JavaScript code or functions.
- System Process Bindings: Associates names with the output of local system commands.
- Element Locators: Locates web elements using selectors, indexes, and shadow DOM options.
Perform Browser Actions with Gwen DSL
Gwen's DSL includes a wide range of actions for web automation:
- Page/Element: Navigate URLs, refresh pages, and interact with elements (click, type, check, send keys).
- Dropdown/Form: Select options by text/value and submit forms.
- Window/Tab/Frame: Manage browser windows, tabs, and switch between iframes.
- Alerts/Popups: Accept, dismiss, and capture messages from browser alerts.
- Advanced: Scroll pages, drag-and-drop elements, and execute arbitrary JavaScript or SQL queries.
- System: Execute local Unix/system processes and manage file attachments/writes.