An automation framework for Construct
- Node.js 14+ - JavaScript runtime
- npm - Node package manager (comes with Node.js)
- Supported Browsers - Chrome, Edge, Firefox (drivers managed automatically)
-
Clone the repository:
git clone https://github.com/Vineyard-Technologies/CAFfeine.git cd CAFfeine -
Install dependencies:
npm install
-
Run the automation:
node src/run_chrome_controller.js
CAFfeine/
βββ src/
β βββ run_chrome_controller.js # Main automation controller
β βββ methods.js # Core automation methods
β βββ position.js # Position utilities
β βββ xpaths.js # XPath repository
βββ images/
β βββ logo.webp # Project assets
βββ package.json # Node.js dependencies
βββ LICENSE # License file
βββ README.md # This file
import { Builder, By } from 'selenium-webdriver';
import { Methods } from './methods.js';
import { Xpaths } from './xpaths.js';
async function main() {
// Setup WebDriver
const driver = await new Builder()
.forBrowser('chrome')
.build();
try {
// Create methods helper
const methods = new Methods(driver);
// Navigate to Construct
await driver.get('https://editor.construct.net/');
// Perform test actions using Methods class
await methods.dismissWelcomeDialog();
// Your test logic here...
} finally {
// Clean up
await driver.quit();
}
}
main().catch(console.error);The Methods class provides utility methods for browser automation:
-
Element Interaction:
clickElement(xpath)- Click elementssendText(xpath, text, clear)- Input textclickableElement(xpath, seconds)- Wait for clickable elements
-
JavaScript Execution:
executeJavascript(script, ...args)- Execute scripts in browsergetPosition(constructObject)- Get Construct object positions
-
Waiting:
waitUntilElementIsGone(xpath, seconds)- Wait for element removal
The Xpaths object organizes all selectors:
// Example usage
await methods.clickElement(Xpaths.Dialog.Welcome.noThanksNotNow);
await methods.clickElement(Xpaths.MenuDropdown.project);node src/run_chrome_controller.jsFrom the root directory:
npm start
# or
npm test- Create a new JavaScript file in the
src/directory - Import the
Methodsclass for utility functions - Import the
Xpathsobject for element selectors - Use async/await patterns for all Selenium operations
- Run using:
node src/your_test.js
The framework outputs information directly to the console, including:
- WebDriver setup and browser launch status
- Element interaction results
- Error messages and stack traces
- Custom debug output from your test implementations
All output is displayed in the console where you run the framework. Monitor for:
- WebDriver initialization messages
- Element interaction confirmations
- JavaScript execution results
- Error messages and exceptions
- Driver Issues: WebDriverManager should automatically handle driver downloads
- Element Not Found: Check XPath selectors in
Xpaths.java - Timing Issues: Adjust wait times in your automation scripts
- XPath Organization: Keep all XPath selectors organized in
xpaths.js - Method Reusability: Use the
Methodsclass for common operations - Async/Await: Always use async/await for Selenium operations
- Error Handling: Use try/catch blocks for proper exception handling
- Resource Cleanup: Always call
driver.quit()in a finally block - ES Modules: Use import/export syntax for better code organization
| Dependency | Version | Purpose |
|---|---|---|
| selenium-webdriver | ^4.34.0 | Web automation framework |
| Node.js | >=14.0.0 | JavaScript runtime |
This project is licensed under the AGPL 3.0 License - see the LICENSE file for details.
