charai 0.2.0.beta2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +110 -3
- data/charai.gemspec +1 -1
- data/lib/charai/input_tool.rb +0 -1
- data/lib/charai/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e29c5d04584453bf1c1c6058a1409eab97233add4ea62d46f3b845831fcd52fa
|
4
|
+
data.tar.gz: f52cc6f53cd78ccf09ef90e58c5e530675c3e4e5c3b19857e48dff2987b25f51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cca134105baa5085a7554311408af3acc33ee5543efab1d62f78bd4a1a28530c3f0dcd8309cbab21f983d7acc734c72b1c78cee30587dfcb03e366847e16293
|
7
|
+
data.tar.gz: 5a6c5dc76e397125bba78a0685a65c638e276c83ced2fb732fb1d64138c28c9b74151cbac55626fb6ae3b18cdac0a157a4f5e8a8f8af61ab4b482f6edf628f97
|
data/README.md
CHANGED
@@ -5,6 +5,14 @@
|
|
5
5
|
|
6
6
|
Chat + Ruby + AI = Charai
|
7
7
|
|
8
|
+
Charai is an AI-powered Capybara driver that enables natural language web testing. Write your E2E tests by describing what you want to test in plain language, and let AI handle the browser interactions.
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
- Ruby 2.7 or higher
|
13
|
+
- Firefox Developer Edition
|
14
|
+
- OpenAI API key or compatible AI service (Azure OpenAI, Gemini, Ollama)
|
15
|
+
|
8
16
|
## Setup
|
9
17
|
|
10
18
|
Add `gem 'charai'` into your project's Gemfile, and then `bundle install`
|
@@ -41,16 +49,75 @@ config = Charai::OpenaiConfiguration.new(
|
|
41
49
|
|
42
50
|
### Azure OpenAI (Recommended)
|
43
51
|
|
44
|
-
```
|
52
|
+
```ruby
|
45
53
|
config = Charai::AzureOpenaiConfiguration.new(
|
46
54
|
endpoint_url: 'https://YOUR-APP.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-05-01-preview',
|
47
55
|
api_key: 'aabbcc00112233445566'
|
48
56
|
)
|
49
57
|
```
|
50
58
|
|
59
|
+
**⚠️ Important Note for Azure OpenAI Environment Variables:**
|
60
|
+
|
61
|
+
When setting the endpoint URL via environment variables, you must include the full path with `/deployments/{model}/chat/completions`:
|
62
|
+
|
63
|
+
```bash
|
64
|
+
# ❌ This will NOT work
|
65
|
+
export AZURE_OPENAI_ENDPOINT_URL="https://your-resource.cognitiveservices.azure.com/openai/responses?api-version=2025-04-01-preview"
|
66
|
+
|
67
|
+
# ✅ This works correctly
|
68
|
+
export AZURE_OPENAI_ENDPOINT_URL="https://your-resource.cognitiveservices.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2025-04-01-preview"
|
69
|
+
```
|
70
|
+
|
71
|
+
The endpoint URL must specify:
|
72
|
+
1. Your Azure resource endpoint
|
73
|
+
2. The deployment name (e.g., `gpt-4o-mini`, `gpt-4o`)
|
74
|
+
3. The `/chat/completions` path
|
75
|
+
4. The API version parameter
|
76
|
+
|
77
|
+
### Gemini
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
config = Charai::GeminiOpenaiConfiguration.new(
|
81
|
+
model: 'gemini-2.0-flash-exp',
|
82
|
+
api_key: 'your-gemini-api-key'
|
83
|
+
)
|
84
|
+
```
|
85
|
+
|
86
|
+
### Ollama (Local AI)
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
config = Charai::OllamaConfiguration.new(
|
90
|
+
endpoint_url: 'http://localhost:11434',
|
91
|
+
model: 'llama3.2'
|
92
|
+
)
|
93
|
+
```
|
94
|
+
|
51
95
|
## Usage
|
52
96
|
|
53
|
-
|
97
|
+
### Basic Example
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
RSpec.describe "Login test", type: :feature do
|
101
|
+
before do
|
102
|
+
Capybara.current_driver = :charai
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should login successfully" do
|
106
|
+
page.driver << <<~MARKDOWN
|
107
|
+
* Navigate to the login page
|
108
|
+
* Enter "user@example.com" in the email field
|
109
|
+
* Enter "password123" in the password field
|
110
|
+
* Click the login button
|
111
|
+
* Verify that you're redirected to the dashboard page
|
112
|
+
* Check that the username "John Doe" is displayed in the header
|
113
|
+
MARKDOWN
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
118
|
+
### Advanced Example with Instructions
|
119
|
+
|
120
|
+
You can provide additional context about your application to help the AI better understand the page structure:
|
54
121
|
|
55
122
|
```ruby
|
56
123
|
before do
|
@@ -165,7 +232,47 @@ config.around(:each, type: :feature) do |example|
|
|
165
232
|
end
|
166
233
|
```
|
167
234
|
|
168
|
-
With this report, we can check evidences for each test and investigate failed tests (
|
235
|
+
With this report, we can check evidences for each test and investigate failed tests (postmortem).
|
236
|
+
|
237
|
+
## Troubleshooting
|
238
|
+
|
239
|
+
### Firefox Developer Edition not found
|
240
|
+
|
241
|
+
Make sure Firefox Developer Edition is installed in the correct location:
|
242
|
+
- macOS: `/Applications/Firefox Developer Edition.app`
|
243
|
+
- Linux: `/usr/bin/firefox-devedition`
|
244
|
+
|
245
|
+
You can also set a custom path:
|
246
|
+
```ruby
|
247
|
+
Charai::Driver.new(app,
|
248
|
+
openai_configuration: config,
|
249
|
+
firefox_path: '/path/to/firefox-dev'
|
250
|
+
)
|
251
|
+
```
|
252
|
+
|
253
|
+
### AI not understanding the page
|
254
|
+
|
255
|
+
Provide more context using `additional_instruction`:
|
256
|
+
```ruby
|
257
|
+
page.driver.additional_instruction = <<~MARKDOWN
|
258
|
+
* This is a single-page application (SPA)
|
259
|
+
* Wait for elements to load before interacting
|
260
|
+
* The main navigation is in a hamburger menu on mobile
|
261
|
+
MARKDOWN
|
262
|
+
```
|
263
|
+
|
264
|
+
### Tests running slowly
|
265
|
+
|
266
|
+
Consider using a faster AI model or running in headless mode:
|
267
|
+
```ruby
|
268
|
+
Capybara.current_driver = :charai_headless
|
269
|
+
```
|
270
|
+
|
271
|
+
## Links
|
272
|
+
|
273
|
+
- [GitHub Repository](https://github.com/YusukeIwaki/charai)
|
274
|
+
- [RubyGems Page](https://rubygems.org/gems/charai)
|
275
|
+
- [Report Issues](https://github.com/YusukeIwaki/charai/issues)
|
169
276
|
|
170
277
|
## License
|
171
278
|
|
data/charai.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["q7w8e9w8q7w8e9@yahoo.co.jp"]
|
10
10
|
|
11
11
|
spec.summary = "charai(Chat + Ruby + AI) Capybara driver"
|
12
|
-
spec.description = "Prototype impl for Kaigi on Rails 2024 presentation."
|
12
|
+
spec.description = "Prototype impl for Kaigi on Rails 2024 & 2025 presentation."
|
13
13
|
spec.homepage = "https://github.com/YusukeIwaki/charai"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 3.2.0"
|
data/lib/charai/input_tool.rb
CHANGED
@@ -60,7 +60,6 @@ module Charai
|
|
60
60
|
trigger_callback(:on_action_start, 'capture_screenshot', {})
|
61
61
|
|
62
62
|
current_url = @browsing_context.url
|
63
|
-
binding.irb
|
64
63
|
@browsing_context.capture_screenshot(format: { type: 'png' }).tap do |binary|
|
65
64
|
if @message_sender
|
66
65
|
message = Agent::Message.new(
|
data/lib/charai/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.6.1
|
55
|
-
description: Prototype impl for Kaigi on Rails 2024 presentation.
|
55
|
+
description: Prototype impl for Kaigi on Rails 2024 & 2025 presentation.
|
56
56
|
email:
|
57
57
|
- q7w8e9w8q7w8e9@yahoo.co.jp
|
58
58
|
executables: []
|