Add Reusable Custom Step Definitions for Advanced DOM Interaction in Kraken Tests #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Advanced Custom Kraken Steps for Contextual UI Interactions and Assertions
This section documents a comprehensive set of advanced custom step definitions for Kraken end-to-end testing with Cucumber. These steps significantly enhance the flexibility, readability, and maintainability of test scenarios, especially when dealing with complex or dynamic DOM structures.
Key contributions:
Keyboard Interactions:
Adds a step to simulate special key presses such as Enter, Esc, Tab, ArrowUp, and ArrowDown using Unicode mappings.
Screenshots:
Implements automatic screenshot capture steps that store the image in a structured directory based on the test version and feature name.
URL Validation:
Introduces a step to wait for and assert the current URL, validating navigation or redirection behavior.
Flexible Element Selection and Interaction:
Adds several click, clear, and enter steps that support:
• Direct selector targeting.
• Contextual targeting via closest parent.
• Targeting within parent located via a child reference.
This allows for precise, conflict-free interactions even in nested or repeated DOM structures.
DOM Traversal Utilities:
Includes helper functions closest and find:
• closest: Recursively finds the nearest ancestor matching a given class selector.
• find: Selects the first matching child within a given parent element.
Robust Field Manipulation:
Steps to clear and enter text with context-aware scope, ensuring clean input even in nested components or similar forms.
Text Assertions:
(Partially shown) Includes assertion steps to check for specific text content within elements.
These custom steps allow testers to write more expressive and modular Cucumber scenarios while minimizing selector collisions and ensuring consistent interaction with dynamic frontends.
This enhancement improves reusability across different versions or UI states of the application, laying the groundwork for scalable and maintainable E2E testing practices with Kraken.