This guide helps you quickly set up and start using AI features in your existing K11 TechLab framework.
Add these dependencies to your existing pom.xml:
<!-- AI/ML Dependencies -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>9.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>9.8.0</version>
</dependency>- Download Ollama from https://ollama.ai/download/windows
- Install and run Ollama
- Open PowerShell and run:
ollama pull llama3:8b
ollama pull codellama:7b- Download from https://lmstudio.ai/
- Install and open LM Studio
- Download a suitable model (Llama 3 8B or CodeLlama 7B)
- Start the local server
Run the AI demo test to verify everything works:
mvn clean test -Dtest=AIEnhancedTestDemopublic class YourTest extends AIEnhancedBaseTest {
@Test
public void testWithAI() {
getDriver().get("https://example.com");
// Get AI-suggested locators
List<String> locators = getSmartLocators("login button");
// Get wait strategy suggestions
String waitAdvice = getWaitSuggestion("button", "click");
// Generate test data
String testData = generateTestData("user", "login test");
// Your test logic here...
}
}- Enable Windows Voice Recognition
- Use voice commands like:
- "Generate test for login page"
- "Create page object for checkout"
- "Suggest wait strategy for button click"
Create ai-config.properties in your src/main/resources/:
# AI Configuration
ai.enabled=true
ai.provider=ollama
ai.model=llama3:8b
ai.url=http://localhost:11434
ai.temperature=0.3
ai.max.tokens=1500
# RAG Configuration
rag.index.enabled=true
rag.index.paths=src/main/java,src/test/java
rag.refresh.interval=3600- Analyzes page structure
- Suggests stable locators
- Validates locator quality
- Provides alternatives
- Creates tests from descriptions
- Follows existing patterns
- Includes proper assertions
- Handles error cases
- Context-aware suggestions
- Framework-specific recommendations
- Performance optimized
- Reduces flaky tests
- Root cause identification
- Fix suggestions
- Pattern recognition
- Prevention advice
- Natural language commands
- Hands-free test creation
- Voice-to-code generation
- Scenario dictation
Check if Ollama is running: ollama list
Test connectivity: curl http://localhost:11434/api/tags
- Use smaller models (7B instead of 13B)
- Increase timeout values
- Reduce context size
- Close other applications
- Use GPU acceleration if available
- Consider cloud deployment
- Explore Examples: Look at
AIEnhancedTestDemo.java - Customize Prompts: Modify generation templates
- Add More Models: Try different LLMs for comparison
- Integrate CI/CD: Add AI analysis to your pipeline
- Train Custom Models: Fine-tune on your codebase
# Start Ollama service
ollama serve
# Test AI health
java -cp target/test-classes org.k11techlab.framework.ai.HealthChecker
# Generate page object
java -cp target/test-classes org.k11techlab.framework.ai.generators.PageObjectGenerator "https://example.com" "LoginPage"
# Analyze test failures
java -cp target/test-classes org.k11techlab.framework.ai.FailureAnalyzer "target/surefire-reports/"- All processing happens locally (no data leaves your machine)
- No API keys or external services required
- Complete offline capability
- Full control over data and models
- Start Small: Begin with locator suggestions and test data
- Iterate: Refine prompts based on results
- Combine: Use AI with manual expertise
- Monitor: Track AI suggestions accuracy
- Customize: Adapt to your specific domain and patterns
Happy AI-Enhanced Testing! 🚀