chromate-rb 0.0.1.pre β 0.0.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +54 -3
- data/README.md +33 -6
- data/Rakefile +48 -16
- data/docker_root/Gemfile +4 -0
- data/docker_root/Gemfile.lock +28 -0
- data/docker_root/TestInDocker.gif +0 -0
- data/docker_root/app.rb +92 -0
- data/dockerfiles/Dockerfile +21 -7
- data/dockerfiles/README.md +49 -0
- data/docs/README.md +74 -0
- data/docs/browser.md +149 -92
- data/docs/element.md +289 -0
- data/lib/bot_browser/downloader.rb +52 -0
- data/lib/bot_browser/installer.rb +81 -0
- data/lib/bot_browser.rb +39 -0
- data/lib/chromate/actions/dom.rb +28 -9
- data/lib/chromate/actions/navigate.rb +4 -5
- data/lib/chromate/actions/screenshot.rb +30 -11
- data/lib/chromate/actions/stealth.rb +47 -0
- data/lib/chromate/browser.rb +64 -12
- data/lib/chromate/c_logger.rb +7 -0
- data/lib/chromate/client.rb +40 -18
- data/lib/chromate/configuration.rb +31 -14
- data/lib/chromate/element.rb +65 -15
- data/lib/chromate/elements/select.rb +59 -7
- data/lib/chromate/hardwares/keyboard_controller.rb +34 -0
- data/lib/chromate/hardwares/keyboards/virtual_controller.rb +65 -0
- data/lib/chromate/hardwares/mouse_controller.rb +47 -11
- data/lib/chromate/hardwares/mouses/linux_controller.rb +124 -21
- data/lib/chromate/hardwares/mouses/mac_os_controller.rb +6 -6
- data/lib/chromate/hardwares/mouses/virtual_controller.rb +95 -7
- data/lib/chromate/hardwares/mouses/x11.rb +36 -0
- data/lib/chromate/hardwares.rb +16 -0
- data/lib/chromate/helpers.rb +22 -15
- data/lib/chromate/user_agent.rb +39 -15
- data/lib/chromate/version.rb +1 -1
- data/lib/chromate.rb +2 -0
- data/logo.png +0 -0
- data/results/bot.png +0 -0
- data/results/brotector.png +0 -0
- data/results/cloudflare.png +0 -0
- data/results/headers.png +0 -0
- data/results/pixelscan.png +0 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d230805cd031a51b1d63131bf6dfba4692d46e7d1d8789a949c4767e461911e
|
4
|
+
data.tar.gz: 408a79332c2fdd4d96b28e53b149bbda859bcc1e621186a7911a3264d1673363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfe50cf45e2261fe0bcc7c03a0b66aa91f54c787a7688133b4722dde1bc22f86bcc0379b3b396efc2ea3c8257ac6d2755879d68796d637dd77025cc28b871e01
|
7
|
+
data.tar.gz: 2b7b59b031a8302f716abb8405bc9e7d67fce3077493b368924d53865e31475ee6356bd0c617a74ea32ac97ca600f572e306d62887aa40236bf87bc10e6ac4a4
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,56 @@
|
|
1
|
-
|
1
|
+
# [Unreleased]
|
2
2
|
|
3
|
-
##
|
3
|
+
## π Features
|
4
|
+
- **Add keyboard actions**: Implemented keyboard interactions, including typing and key pressing.
|
5
|
+
- **Add drag and drop action**: Implemented drag and drop bewteen elements
|
4
6
|
|
5
|
-
|
7
|
+
## π Core Enhancements
|
8
|
+
- **Improve mouse movements**: Keep mouse position between interaction during browser session
|
9
|
+
- **Improve mouse movements**: Improving BΓ©zier curve usage for more human like behavior
|
10
|
+
|
11
|
+
# Changelog v0.0.1.pre
|
12
|
+
|
13
|
+
## π Features
|
14
|
+
- **Add virtual mouse on macOS**: Introduced a virtual mouse controller for macOS. (commit `9cb095b`)
|
15
|
+
- **Abstract mouse control**: Unified mouse control across different operating systems with an abstraction layer. (commit `a7e0732`)
|
16
|
+
- **Add shadow interactor**: Added support for interacting with elements inside shadow DOM. (commit `6cdea5c`)
|
17
|
+
|
18
|
+
## π Core Enhancements
|
19
|
+
- **Add debug_url spec**: Introduced debug specifications for better error tracking. (commit `4c06c75`)
|
20
|
+
- **Add client specs**: Comprehensive tests for the core client functionality. (commits `1e17955`, `18f0bf1`)
|
21
|
+
- **Add config spec**: Added configuration testing specs. (commit `588407f`)
|
22
|
+
- **Add MPEG for recording**: Integrated MPEG support for screen recording (currently experimental). (commit `d149a14`)
|
23
|
+
- **Improve arguments priority**: Refined the argument handling mechanism for better control. (commit `9849d0f`)
|
24
|
+
- **Add Dockerfile for testing**: Included a Docker setup for running tests in isolated environments. (commit `57f334e`)
|
25
|
+
- **Use xdotool for Linux and add X screenshot**: Enhanced Linux support using `xdotool` for mouse control and added X screenshot capability. (commit `80ef37f`)
|
26
|
+
- **Improve wait for load**: Improved logic for waiting until the page is fully loaded before proceeding. (commit `28e9371`)
|
27
|
+
- **Improve DOM events**: Enhanced handling of DOM events for better interaction. (commit `36a425c`)
|
28
|
+
- **Improve nested elements handling**: Enhanced support for working with nested and complex elements. (commit `ad03ec3`)
|
29
|
+
- **Get element attributes**: Added method to retrieve element attributes as a hash. (commit `b71e1f7`)
|
30
|
+
- **Add WEBrick for testing server**: Added a simple WEBrick server for testing purposes. (commit `fc70006`)
|
31
|
+
- **Improve element interactions**: Various improvements in element manipulation methods. (commit `5430d8c`)
|
32
|
+
- **Start native mouse support**: Began implementation of native mouse interactions. (commit `fce1aef`)
|
33
|
+
- **Improve undetection mechanisms**: Enhanced techniques to bypass bot detection. (commit `7ff622a`)
|
34
|
+
|
35
|
+
## π Bug Fixes
|
36
|
+
- **Fix bad stop method**: Corrected an issue with the stopping method that caused unexpected behavior. (commit `4b45d6d`)
|
37
|
+
- **Fix Docker X size**: Resolved issues with the size of the X window in Docker environments. (commit `41edece`)
|
38
|
+
|
39
|
+
## π Documentation
|
40
|
+
- **Update README**: Updated the README file with new instructions and examples. (commit `8118913`)
|
41
|
+
- **Add logo**: Added a logo to the project for better branding. (commit `2a5cbb9`)
|
42
|
+
|
43
|
+
## π§ͺ CI/CD
|
44
|
+
- **Enable CI pipeline**: Added continuous integration (CI) setup for automated testing. (commit `4160aa1`)
|
45
|
+
|
46
|
+
## π§Ή Refactor
|
47
|
+
- **Rename mouse hardware**: Refactored the naming conventions for mouse-related classes. (commit `89d6ae1`)
|
48
|
+
- **Remove record notion (temporary)**: Temporarily removed the recording feature for further refinement. (commit `fdb3e0e`)
|
49
|
+
|
50
|
+
## π Infrastructure
|
51
|
+
- **Start adding Xvfb support**: Introduced Xvfb support for headless testing. (commit `678a8a5`)
|
52
|
+
- **Improve spec servers**: Made enhancements to the testing servers for more robust specs. (commit `51e64f4`)
|
53
|
+
|
54
|
+
## π Project Initialization
|
55
|
+
- **Initialize project**: Set up the initial project structure. (commit `3ec91f4`)
|
56
|
+
- **Start element development**: Began the implementation of the `Element` class. (commit `adadef0`)
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Chromate
|
2
|
-
[![eth3rnit3 - chromate](https://img.shields.io/static/v1?label=eth3rnit3&message=chromate&color=
|
3
|
-
[![GitHub release](https://img.shields.io/github/release/eth3rnit3/chromate?include_prereleases=&sort=semver&color=
|
2
|
+
[![eth3rnit3 - chromate](https://img.shields.io/static/v1?label=eth3rnit3&message=chromate&color=a8a9ad&logo=ruby&labelColor=9b111e)](https://github.com/eth3rnit3/chromate "Go to GitHub repo")
|
3
|
+
[![GitHub release](https://img.shields.io/github/release/eth3rnit3/chromate?include_prereleases=&sort=semver&color=a8a9ad)](https://github.com/eth3rnit3/chromate/releases/)
|
4
|
+
[![License](https://img.shields.io/badge/License-MIT-a8a9ad)](#license)
|
4
5
|
[![Ruby](https://github.com/Eth3rnit3/chromate/actions/workflows/main.yml/badge.svg)](https://github.com/Eth3rnit3/chromate/actions/workflows/main.yml)
|
5
6
|
[![issues - chromate](https://img.shields.io/github/issues/eth3rnit3/chromate)](https://github.com/eth3rnit3/chromate/issues)
|
6
|
-
|
7
|
+
|
8
|
+
![logo](logo.png)
|
7
9
|
|
8
10
|
Chromate is a custom driver for Chrome using the Chrome DevTools Protocol (CDP) to create undetectable bots with human-like behavior. The ultimate goal is to enable the creation of AI agents capable of navigating and performing actions on the web on behalf of the user. This gem is the first step towards achieving that goal.
|
9
11
|
|
@@ -12,13 +14,30 @@ Chromate is a custom driver for Chrome using the Chrome DevTools Protocol (CDP)
|
|
12
14
|
Add gem to your application's Gemfile:
|
13
15
|
|
14
16
|
```sh
|
15
|
-
|
17
|
+
# Github pkgs
|
18
|
+
bundle add chromate --source https://rubygems.pkg.github.com/eth3rnit3
|
19
|
+
|
20
|
+
# Or add manualy within a block
|
21
|
+
# source "https://rubygems.pkg.github.com/eth3rnit3" do
|
22
|
+
# gem "chromate"
|
23
|
+
# end
|
24
|
+
|
25
|
+
# or
|
26
|
+
|
27
|
+
# Rubygems
|
28
|
+
bundle add chromate-rb
|
29
|
+
|
16
30
|
```
|
17
31
|
|
18
32
|
Or install it yourself as:
|
19
33
|
|
20
34
|
```sh
|
21
|
-
|
35
|
+
# Github pkgs
|
36
|
+
gem install chromate --source https://rubygems.pkg.github.com/eth3rnit3
|
37
|
+
|
38
|
+
# or
|
39
|
+
|
40
|
+
gem install chromate-rb
|
22
41
|
```
|
23
42
|
|
24
43
|
## Usage
|
@@ -36,7 +55,7 @@ browser.start
|
|
36
55
|
url = 'http://example.com'
|
37
56
|
browser.navigate_to(url)
|
38
57
|
browser.find_element('#some-element').click
|
39
|
-
browser.
|
58
|
+
browser.screenshot('screenshot.png')
|
40
59
|
|
41
60
|
browser.stop
|
42
61
|
```
|
@@ -106,6 +125,14 @@ ruby your_script.rb # or bundle exec rspec
|
|
106
125
|
|
107
126
|
This setup ensures that all necessary dependencies are installed and configured correctly, allowing you to focus on writing your automation scripts without worrying about the underlying environment.
|
108
127
|
|
128
|
+
## Disclaimer
|
129
|
+
|
130
|
+
**Chromate** is an open-source project designed to provide a solid foundation for the creation of autonomous AI agents, fostering innovation and development in the field of artificial intelligence. This project is developed with an educational and collaborative spirit, aiming to promote responsible and ethical usage.
|
131
|
+
|
132
|
+
Under no circumstances is **Chromate** intended to be used for creating automated bots, scraping tools, or any other activities that violate platform policies or applicable laws. The author disclaims any responsibility for improper or illegal use of this project.
|
133
|
+
|
134
|
+
Users are encouraged to comply with platform terms of service and to adopt practices that adhere to ethical and legal standards.
|
135
|
+
|
109
136
|
## Contribution
|
110
137
|
|
111
138
|
Contributions are welcome! If you have suggestions for improvements or new features, please open an issue or submit a pull request on GitHub.
|
data/Rakefile
CHANGED
@@ -12,9 +12,12 @@ RuboCop::RakeTask.new
|
|
12
12
|
task default: %i[spec rubocop]
|
13
13
|
|
14
14
|
require_relative "lib/chromate"
|
15
|
+
require_relative 'spec/support/modes'
|
15
16
|
|
16
17
|
namespace :chromate do
|
17
18
|
namespace :test do
|
19
|
+
include Support::Modes
|
20
|
+
|
18
21
|
task :open do
|
19
22
|
browser = Chromate::Browser.new(headless: false)
|
20
23
|
browser.start
|
@@ -25,46 +28,75 @@ namespace :chromate do
|
|
25
28
|
browser.stop
|
26
29
|
end
|
27
30
|
|
31
|
+
# Xfvb mode
|
32
|
+
# docker run -it --rm -v $(pwd):/app --env CHROMATE_MODE=docker-xvfb chromate:latest bundle exec rake chromate:test:all
|
33
|
+
|
34
|
+
# BotBrowser mode
|
35
|
+
# docker run -it --rm -v $(pwd):/app --env CHROMATE_MODE=bot-browser chromate:latest bundle exec rake chromate:test:all
|
36
|
+
|
37
|
+
# Default mode
|
38
|
+
# docker run -it --rm -v $(pwd):/app chromate:latest bundle exec rake chromate:test:all
|
39
|
+
task :all do
|
40
|
+
Rake::Task["chromate:test:pixelscan"].invoke
|
41
|
+
Rake::Task["chromate:test:brotector"].invoke
|
42
|
+
Rake::Task["chromate:test:bot"].invoke
|
43
|
+
Rake::Task["chromate:test:cloudflare"].invoke
|
44
|
+
end
|
45
|
+
|
28
46
|
task :pixelscan do
|
29
|
-
browser = Chromate::Browser.new
|
47
|
+
browser = Chromate::Browser.new(browser_args)
|
30
48
|
browser.start
|
31
49
|
browser.navigate_to("https://pixelscan.net")
|
32
50
|
sleep 10
|
33
|
-
browser.
|
51
|
+
browser.screenshot("results/pixelscan.png")
|
34
52
|
browser.stop
|
35
53
|
end
|
36
54
|
|
37
55
|
task :brotector do
|
38
|
-
|
39
|
-
browser = Chromate::Browser.new
|
56
|
+
browser = Chromate::Browser.new(browser_args)
|
40
57
|
browser.start
|
41
|
-
browser.navigate_to("https://kaliiiiiiiiii.github.io/brotector
|
58
|
+
browser.navigate_to("https://kaliiiiiiiiii.github.io/brotector")
|
42
59
|
sleep 2
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
browser.screenshot_to_file("results/brotector.png")
|
60
|
+
browser.click_element("#clickHere")
|
61
|
+
sleep 3
|
62
|
+
browser.screenshot("results/brotector.png")
|
47
63
|
browser.stop
|
48
64
|
end
|
49
65
|
|
50
66
|
task :bot do
|
51
|
-
browser = Chromate::Browser.new
|
67
|
+
browser = Chromate::Browser.new(browser_args)
|
52
68
|
browser.start
|
53
69
|
browser.navigate_to("https://bot.sannysoft.com")
|
54
70
|
sleep 2
|
55
|
-
browser.
|
71
|
+
browser.screenshot("results/bot.png")
|
56
72
|
browser.stop
|
57
73
|
end
|
58
74
|
|
59
75
|
task :cloudflare do
|
60
|
-
Chromate.
|
61
|
-
config.headless = false
|
62
|
-
end
|
63
|
-
browser = Chromate::Browser.new
|
76
|
+
browser = Chromate::Browser.new(browser_args)
|
64
77
|
browser.start
|
65
78
|
browser.navigate_to("https://2captcha.com/fr/demo/cloudflare-turnstile-challenge")
|
66
79
|
sleep 10
|
67
|
-
browser.
|
80
|
+
browser.screenshot("results/cloudflare.png")
|
81
|
+
browser.stop
|
82
|
+
end
|
83
|
+
|
84
|
+
task :my_ip do
|
85
|
+
browser = Chromate::Browser.new(browser_args)
|
86
|
+
browser.start
|
87
|
+
browser.navigate_to("https://whatismyipaddress.com")
|
88
|
+
sleep 2
|
89
|
+
browser.click_element('//*[@id="qc-cmp2-ui"]/div[2]/div/button[3]')
|
90
|
+
browser.screenshot("results/my_ip.png")
|
91
|
+
browser.stop
|
92
|
+
end
|
93
|
+
|
94
|
+
task :headers do
|
95
|
+
browser = Chromate::Browser.new(browser_args)
|
96
|
+
browser.start
|
97
|
+
browser.navigate_to("https://httpbin.org/headers")
|
98
|
+
sleep 2
|
99
|
+
browser.screenshot("results/headers.png")
|
68
100
|
browser.stop
|
69
101
|
end
|
70
102
|
end
|
data/docker_root/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /chromate
|
3
|
+
specs:
|
4
|
+
chromate (0.0.1.pre)
|
5
|
+
ffi (~> 1.17.0)
|
6
|
+
websocket-client-simple (~> 0.8.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
event_emitter (0.2.6)
|
12
|
+
ffi (1.17.0)
|
13
|
+
webrick (1.8.2)
|
14
|
+
websocket (1.2.11)
|
15
|
+
websocket-client-simple (0.8.0)
|
16
|
+
event_emitter
|
17
|
+
websocket
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
x86_64-linux
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
chromate!
|
25
|
+
webrick
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
2.5.21
|
Binary file
|
data/docker_root/app.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'chromate'
|
3
|
+
require '/chromate/spec/support/server'
|
4
|
+
|
5
|
+
class TestInDocker
|
6
|
+
include Support::Server
|
7
|
+
|
8
|
+
attr_reader :browser
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
start_servers
|
12
|
+
|
13
|
+
@browser = Chromate::Browser.new(headless: false, xfvb: true, record: 'record.mp4', native_control: false)
|
14
|
+
@browser.start
|
15
|
+
|
16
|
+
trap('INT') { stop }
|
17
|
+
trap('TERM') { stop }
|
18
|
+
|
19
|
+
at_exit { stop }
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop
|
23
|
+
@browser.stop
|
24
|
+
stop_servers
|
25
|
+
# Convert the video to a gif
|
26
|
+
pid = spawn('ffmpeg -i record.mp4 -vf "fps=10,scale=640:-1:flags=lanczos,palettegen" palette.png')
|
27
|
+
Process.wait(pid)
|
28
|
+
pid = spawn('ffmpeg -i record.mp4 -i palette.png -filter_complex "fps=10,scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse" TestInDocker.gif')
|
29
|
+
Process.wait(pid)
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
click_features
|
34
|
+
move_features
|
35
|
+
drag_and_drop_features
|
36
|
+
fill_form_features
|
37
|
+
shadow_dom_features
|
38
|
+
end
|
39
|
+
|
40
|
+
def click_features
|
41
|
+
url = server_urls['where_clicked']
|
42
|
+
browser.navigate_to(url)
|
43
|
+
browser.refresh
|
44
|
+
browser.click_element('#interactive-button')
|
45
|
+
sleep 1
|
46
|
+
end
|
47
|
+
|
48
|
+
def move_features
|
49
|
+
url = server_urls['where_moved']
|
50
|
+
browser.navigate_to(url)
|
51
|
+
browser.refresh
|
52
|
+
browser.hover_element('#red')
|
53
|
+
browser.hover_element('#yellow')
|
54
|
+
browser.hover_element('#green')
|
55
|
+
browser.hover_element('#blue')
|
56
|
+
sleep 1
|
57
|
+
end
|
58
|
+
|
59
|
+
def drag_and_drop_features
|
60
|
+
url = server_urls['drag_and_drop']
|
61
|
+
browser.navigate_to(url)
|
62
|
+
browser.refresh
|
63
|
+
blue_square = browser.find_element('#draggable')
|
64
|
+
green_square = browser.find_element('#dropzone')
|
65
|
+
blue_square.drop_to(green_square)
|
66
|
+
sleep 1
|
67
|
+
end
|
68
|
+
|
69
|
+
def fill_form_features
|
70
|
+
url = server_urls['fill_form']
|
71
|
+
browser.navigate_to(url)
|
72
|
+
browser.refresh
|
73
|
+
browser.find_element('#first-name').type('John')
|
74
|
+
browser.find_element('#last-name').type('Doe')
|
75
|
+
browser.select_option('#gender', 'female')
|
76
|
+
browser.find_element('#option-2').click
|
77
|
+
browser.find_element('#submit-button').click
|
78
|
+
sleep 1
|
79
|
+
end
|
80
|
+
|
81
|
+
def shadow_dom_features
|
82
|
+
url = server_urls['shadow_checkbox']
|
83
|
+
browser.navigate_to(url)
|
84
|
+
browser.refresh
|
85
|
+
shadow_container = browser.find_element('#shadow-container')
|
86
|
+
checkbox = shadow_container.find_shadow_child('#shadow-checkbox')
|
87
|
+
checkbox.click
|
88
|
+
sleep 1
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
TestInDocker.new.run
|
data/dockerfiles/Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FROM ruby:3.2-slim
|
1
|
+
FROM --platform=linux/amd64 ruby:3.2-slim
|
2
2
|
|
3
3
|
RUN apt-get update && apt-get install -y \
|
4
4
|
nano \
|
@@ -51,18 +51,23 @@ RUN apt-get update && apt-get install -y \
|
|
51
51
|
psmisc \
|
52
52
|
--no-install-recommends && rm -rf /var/lib/apt/lists/*
|
53
53
|
|
54
|
-
#
|
54
|
+
# Préparer le système
|
55
|
+
RUN apt-get update && apt-get install -y wget gnupg2 lsb-release && rm -rf /var/lib/apt/lists/*
|
55
56
|
|
56
|
-
|
57
|
-
RUN wget -q -O
|
58
|
-
|
59
|
-
|
57
|
+
# TΓ©lΓ©charger et ajouter la clΓ© GPG
|
58
|
+
RUN wget -q -O- https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg
|
59
|
+
|
60
|
+
# Ajouter le dΓ©pΓ΄t Google Chrome
|
61
|
+
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list
|
62
|
+
|
63
|
+
# Mise Γ jour et installation de Google Chrome
|
64
|
+
RUN apt-get update && apt-get install -y google-chrome-stable
|
60
65
|
|
61
66
|
ENV CHROME_BIN=/usr/bin/google-chrome
|
62
67
|
|
63
68
|
RUN gem install bundler -v 2.5.21
|
64
69
|
|
65
|
-
WORKDIR /
|
70
|
+
WORKDIR /chromate
|
66
71
|
|
67
72
|
COPY Gemfile Gemfile.lock chromate.gemspec ./
|
68
73
|
COPY lib/chromate/version.rb ./lib/chromate/version.rb
|
@@ -77,9 +82,18 @@ COPY . .
|
|
77
82
|
|
78
83
|
ENV DISPLAY=:99
|
79
84
|
|
85
|
+
WORKDIR /app
|
86
|
+
|
87
|
+
COPY docker_root/ /app/
|
88
|
+
|
80
89
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
81
90
|
|
82
91
|
CMD [ "bash" ]
|
83
92
|
|
84
93
|
# docker build -f dockerfiles/Dockerfile -t chromate .
|
94
|
+
|
95
|
+
# Run the container for testing chromate
|
96
|
+
# docker run -v $(pwd)/docker_root:/app -it chromate
|
97
|
+
|
98
|
+
# Run the container for development
|
85
99
|
# docker run -v $(pwd):/app -it chromate
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Chromate Docker Configuration
|
2
|
+
|
3
|
+
This section explains how to configure and test the Chromate gem using Docker with xvfb support.
|
4
|
+
|
5
|
+
![TestInDocker.gif](../docker_root/TestInDocker.gif)
|
6
|
+
|
7
|
+
## Docker Setup
|
8
|
+
|
9
|
+
To simplify the setup process, Chromate includes a Dockerfile and an entrypoint script that handle the installation and configuration of necessary dependencies, including xvfb.
|
10
|
+
|
11
|
+
### Dockerfile
|
12
|
+
|
13
|
+
The Dockerfile sets up a minimal environment with all the necessary dependencies to run Chromate in headless mode with xvfb. It installs Chrome, xvfb, and other required libraries.
|
14
|
+
|
15
|
+
###
|
16
|
+
|
17
|
+
docker-entrypoint.sh
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
The entrypoint script ensures that xvfb is running before starting the main process. It removes any existing lock files, starts xvfb and a window manager (fluxbox), and waits for xvfb to initialize.
|
22
|
+
|
23
|
+
### How to Use
|
24
|
+
|
25
|
+
1. **Build the Docker Image**
|
26
|
+
|
27
|
+
```sh
|
28
|
+
docker build -f dockerfiles/Dockerfile -t chromate .
|
29
|
+
```
|
30
|
+
|
31
|
+
2. **Run the Docker Container**
|
32
|
+
|
33
|
+
```sh
|
34
|
+
docker run -v $(pwd)/docker_root:/app -it chromate
|
35
|
+
```
|
36
|
+
|
37
|
+
This command mounts the current directory to `/app` inside the container and starts an interactive bash session.
|
38
|
+
|
39
|
+
3. **Run the Test Script**
|
40
|
+
|
41
|
+
Inside the Docker container, run the test script:
|
42
|
+
|
43
|
+
```sh
|
44
|
+
ruby app.rb
|
45
|
+
```
|
46
|
+
|
47
|
+
## Conclusion
|
48
|
+
|
49
|
+
This setup ensures that all necessary dependencies are installed and configured correctly, allowing you to focus on writing your automation scripts without worrying about the underlying environment.
|
data/docs/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Chromate Documentation Index
|
2
|
+
|
3
|
+
Welcome to the Chromate Documentation! This index provides an overview of the main classes and their detailed documentation, covering public methods, usage examples, and key features.
|
4
|
+
|
5
|
+
## π Table of Contents
|
6
|
+
|
7
|
+
1. [Introduction](#introduction)
|
8
|
+
2. [Classes Overview](#classes-overview)
|
9
|
+
3. [Detailed Documentation](#detailed-documentation)
|
10
|
+
- [Chromate::Browser](#1-chromatebrowser-class)
|
11
|
+
- [Chromate::Element](#2-chromateelement-class)
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
## Introduction
|
16
|
+
|
17
|
+
Chromate is a Ruby-based library designed to interact with the Chrome DevTools Protocol (CDP). It allows you to control a headless Chrome browser, manipulate DOM elements, and perform automated tasks such as navigation, screenshot capture, and form submissions.
|
18
|
+
|
19
|
+
This documentation provides a comprehensive guide for the core components of Chromate:
|
20
|
+
|
21
|
+
- **Chromate::Browser**: Manages the browser instance, providing methods for starting, stopping, navigation, and executing browser actions.
|
22
|
+
- **Chromate::Element**: Represents a DOM element, enabling actions like clicking, typing, and attribute manipulation.
|
23
|
+
|
24
|
+
## Classes Overview
|
25
|
+
|
26
|
+
| Class | Description |
|
27
|
+
| ------------------ | ----------------------------------------------------- |
|
28
|
+
| `Chromate::Browser`| A class for controlling the Chrome browser instance. |
|
29
|
+
| `Chromate::Element`| A class for interacting with individual DOM elements. |
|
30
|
+
|
31
|
+
## Detailed Documentation
|
32
|
+
|
33
|
+
### 1. `Chromate::Browser` Class
|
34
|
+
|
35
|
+
The `Browser` class is responsible for managing the lifecycle of a Chrome browser instance. It provides methods for navigation, screenshot capture, and DOM interaction. It also includes features for headless mode, native control, and video recording of sessions.
|
36
|
+
|
37
|
+
- **Features:**
|
38
|
+
- Start and stop the browser instance.
|
39
|
+
- Navigate to URLs, refresh, and go back in browser history.
|
40
|
+
- Capture full-page and Xvfb screenshots.
|
41
|
+
- Execute JavaScript code and interact with DOM elements.
|
42
|
+
|
43
|
+
For the full documentation and usage examples, refer to [Chromate::Browser Documentation](#chromatebrowser-class).
|
44
|
+
|
45
|
+
### 2. `Chromate::Element` Class
|
46
|
+
|
47
|
+
The `Element` class provides a robust interface for interacting with DOM elements in the browser. It includes methods for text extraction, attribute manipulation, and user interaction simulation (click, hover, type).
|
48
|
+
|
49
|
+
- **Features:**
|
50
|
+
- Retrieve text and HTML content of an element.
|
51
|
+
- Set and get element attributes.
|
52
|
+
- Simulate user interactions (click, hover, type).
|
53
|
+
- Interact with shadow DOM elements.
|
54
|
+
|
55
|
+
For the full documentation and usage examples, refer to [Chromate::Element Documentation](#chromateelement-class).
|
56
|
+
|
57
|
+
---
|
58
|
+
|
59
|
+
## How to Get Started
|
60
|
+
|
61
|
+
To start using Chromate in your project, ensure that you have a working installation of Google Chrome and Ruby. Follow the setup instructions provided in the README file of the project.
|
62
|
+
|
63
|
+
Example usage:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
require 'chromate'
|
67
|
+
|
68
|
+
browser = Chromate::Browser.new(headless: true)
|
69
|
+
browser.start
|
70
|
+
browser.navigate_to('https://example.com')
|
71
|
+
element = browser.find_element('#header')
|
72
|
+
puts element.text
|
73
|
+
browser.stop
|
74
|
+
```
|