chromate-rb 0.0.2.pre β†’ 0.0.3.pre

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/CHANGELOG.md +20 -2
  4. data/Rakefile +2 -2
  5. data/docker_root/app.rb +6 -11
  6. data/docs/BOT_BROWSER.md +74 -0
  7. data/docs/browser.md +20 -55
  8. data/docs/client.md +126 -0
  9. data/docs/element.md +77 -1
  10. data/docs/elements/checkbox.md +69 -0
  11. data/docs/elements/radio.md +57 -0
  12. data/lib/bot_browser/downloader.rb +38 -26
  13. data/lib/bot_browser/installer.rb +27 -9
  14. data/lib/bot_browser.rb +5 -1
  15. data/lib/chromate/actions/dom.rb +24 -35
  16. data/lib/chromate/actions/navigate.rb +3 -0
  17. data/lib/chromate/actions/screenshot.rb +52 -14
  18. data/lib/chromate/actions/stealth.rb +38 -23
  19. data/lib/chromate/binary.rb +83 -0
  20. data/lib/chromate/browser.rb +70 -26
  21. data/lib/chromate/c_logger.rb +1 -0
  22. data/lib/chromate/client.rb +25 -8
  23. data/lib/chromate/configuration.rb +2 -2
  24. data/lib/chromate/element.rb +62 -9
  25. data/lib/chromate/elements/checkbox.rb +40 -0
  26. data/lib/chromate/elements/option.rb +43 -0
  27. data/lib/chromate/elements/radio.rb +37 -0
  28. data/lib/chromate/elements/select.rb +10 -18
  29. data/lib/chromate/elements/tags.rb +29 -0
  30. data/lib/chromate/exceptions.rb +2 -0
  31. data/lib/chromate/files/agents.json +11 -0
  32. data/lib/chromate/files/stealth.js +199 -0
  33. data/lib/chromate/hardwares/keyboard_controller.rb +11 -0
  34. data/lib/chromate/hardwares/mouse_controller.rb +8 -0
  35. data/lib/chromate/hardwares.rb +4 -4
  36. data/lib/chromate/user_agent.rb +14 -12
  37. data/lib/chromate/version.rb +1 -1
  38. data/results/bot.png +0 -0
  39. data/results/brotector.png +0 -0
  40. data/results/cloudflare.png +0 -0
  41. data/results/pixelscan.png +0 -0
  42. metadata +27 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d230805cd031a51b1d63131bf6dfba4692d46e7d1d8789a949c4767e461911e
4
- data.tar.gz: 408a79332c2fdd4d96b28e53b149bbda859bcc1e621186a7911a3264d1673363
3
+ metadata.gz: 69be8ab00b56202a699439b91f9578f662570c4686fd290aa2c151d0f843b18d
4
+ data.tar.gz: 9513eee5138f694a31d628f0fbb63ced5c750c4e9213967c27a9cacddc04f799
5
5
  SHA512:
6
- metadata.gz: cfe50cf45e2261fe0bcc7c03a0b66aa91f54c787a7688133b4722dde1bc22f86bcc0379b3b396efc2ea3c8257ac6d2755879d68796d637dd77025cc28b871e01
7
- data.tar.gz: 2b7b59b031a8302f716abb8405bc9e7d67fce3077493b368924d53865e31475ee6356bd0c617a74ea32ac97ca600f572e306d62887aa40236bf87bc10e6ac4a4
6
+ metadata.gz: ee7d1248c446032c9940c3f63b8161e2c1350800c55bcff78bec2f0bf65363c2befcf2f135171f24c1987a996935d590e50b63b12dbc2bb3ddca7ce54ade95fd
7
+ data.tar.gz: ac9446088c14121f78cb7b53cce6cdaf3b71f8b0b1a1f89c8ec940ed8844e9f97eddaa87fb0533f4771fcd6fb3c0f8249edbba80b1f9d3adfbeb85dce5f60d49
data/.rubocop.yml CHANGED
@@ -5,6 +5,7 @@ AllCops:
5
5
  - 'Rakefile'
6
6
  - 'bin/**/*'
7
7
  - 'vendor/**/*'
8
+ - 'spec/support/**/*'
8
9
  - 'docker_root/**/*'
9
10
 
10
11
  Style/StringLiterals:
data/CHANGELOG.md CHANGED
@@ -1,12 +1,30 @@
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
+ - **Add specialized elements**: Added support for Select, Radio, and Checkbox elements with specific behaviors
5
+
6
+ ## πŸ›  Core Enhancements
7
+ - **Optimize element initialization**: Reduced redundant element searches by reusing element information
8
+ - **Add native option select**: Added support for native select option handling
9
+ - **Improve element attributes**: Exposed element attributes (node_id, object_id, root_id) for better control
10
+ - **Add BotBrowser binary usage**: Integrated BotBrowser binary for improved automation capabilities
11
+
12
+ # Changelog v0.0.2.pre
13
+
14
+ ## πŸš€ Features
15
+ - **Add keyboard actions**: Implemented keyboard interactions, including typing and key pressing
16
+ - **Add drag and drop action**: Implemented drag and drop between elements
17
+ - **Add b64 screenshot option**: Added support for base64 encoded screenshots
6
18
 
7
19
  ## πŸ›  Core Enhancements
8
20
  - **Improve mouse movements**: Keep mouse position between interaction during browser session
9
21
  - **Improve mouse movements**: Improving BΓ©zier curve usage for more human like behavior
22
+ - **Add log level**: Added configurable logging levels
23
+ - **Keep hardwares during session**: Maintain hardware state throughout the browser session
24
+ - **Add magick find**: Enhanced element finding capabilities
25
+ - **Refactor callFunctionOn usage**: Improved JavaScript function calling mechanism
26
+ - **Add started? method**: New method to check browser startup status
27
+ - **Wait for debug url**: Enhanced browser startup synchronization
10
28
 
11
29
  # Changelog v0.0.1.pre
12
30
 
data/Rakefile CHANGED
@@ -57,7 +57,7 @@ namespace :chromate do
57
57
  browser.start
58
58
  browser.navigate_to("https://kaliiiiiiiiii.github.io/brotector")
59
59
  sleep 2
60
- browser.click_element("#clickHere")
60
+ browser.find_element("#clickHere").click
61
61
  sleep 3
62
62
  browser.screenshot("results/brotector.png")
63
63
  browser.stop
@@ -86,7 +86,7 @@ namespace :chromate do
86
86
  browser.start
87
87
  browser.navigate_to("https://whatismyipaddress.com")
88
88
  sleep 2
89
- browser.click_element('//*[@id="qc-cmp2-ui"]/div[2]/div/button[3]')
89
+ browser.find_element('//*[@id="qc-cmp2-ui"]/div[2]/div/button[3]').click
90
90
  browser.screenshot("results/my_ip.png")
91
91
  browser.stop
92
92
  end
data/docker_root/app.rb CHANGED
@@ -40,26 +40,23 @@ class TestInDocker
40
40
  def click_features
41
41
  url = server_urls['where_clicked']
42
42
  browser.navigate_to(url)
43
- browser.refresh
44
- browser.click_element('#interactive-button')
43
+ browser.find_element('#interactive-button').click
45
44
  sleep 1
46
45
  end
47
46
 
48
47
  def move_features
49
48
  url = server_urls['where_moved']
50
49
  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')
50
+ browser.find_element('#red').hover
51
+ browser.find_element('#yellow').hover
52
+ browser.find_element('#green').hover
53
+ browser.find_element('#blue').hover
56
54
  sleep 1
57
55
  end
58
56
 
59
57
  def drag_and_drop_features
60
58
  url = server_urls['drag_and_drop']
61
59
  browser.navigate_to(url)
62
- browser.refresh
63
60
  blue_square = browser.find_element('#draggable')
64
61
  green_square = browser.find_element('#dropzone')
65
62
  blue_square.drop_to(green_square)
@@ -69,10 +66,9 @@ class TestInDocker
69
66
  def fill_form_features
70
67
  url = server_urls['fill_form']
71
68
  browser.navigate_to(url)
72
- browser.refresh
73
69
  browser.find_element('#first-name').type('John')
74
70
  browser.find_element('#last-name').type('Doe')
75
- browser.select_option('#gender', 'female')
71
+ browser.find_element('#gender').select_option('female')
76
72
  browser.find_element('#option-2').click
77
73
  browser.find_element('#submit-button').click
78
74
  sleep 1
@@ -81,7 +77,6 @@ class TestInDocker
81
77
  def shadow_dom_features
82
78
  url = server_urls['shadow_checkbox']
83
79
  browser.navigate_to(url)
84
- browser.refresh
85
80
  shadow_container = browser.find_element('#shadow-container')
86
81
  checkbox = shadow_container.find_shadow_child('#shadow-checkbox')
87
82
  checkbox.click
@@ -0,0 +1,74 @@
1
+ # BotBrowser Documentation
2
+
3
+ BotBrowser is a specialized configuration module for Chromate that helps you manage and use a specific Chrome browser installation for bot automation purposes.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Installation](#installation)
8
+ 2. [Usage](#usage)
9
+ 3. [Configuration](#configuration)
10
+ 4. [API Reference](#api-reference)
11
+
12
+ ## Installation
13
+
14
+ First, require the BotBrowser module in your Ruby code:
15
+
16
+ ```ruby
17
+ require 'bot_browser'
18
+ ```
19
+
20
+ Then, install the browser:
21
+
22
+ ```ruby
23
+ # Install the latest version
24
+ BotBrowser.install
25
+
26
+ # Or install a specific version
27
+ BotBrowser.install('v130')
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ Here's a basic example of how to use BotBrowser with Chromate:
33
+
34
+ ```ruby
35
+ require 'bot_browser'
36
+
37
+ # Install the browser if not already installed
38
+ BotBrowser.install unless BotBrowser.installed?
39
+
40
+ # Load the BotBrowser configuration
41
+ BotBrowser.load
42
+
43
+ # Create a new browser instance
44
+ browser = Chromate::Browser.new
45
+
46
+ # Use the browser as you would normally with Chromate
47
+ browser.navigate_to('https://example.com')
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ BotBrowser uses a configuration file located at `~/.botbrowser/config.yml`. This file is automatically created during installation and contains:
53
+
54
+ - `bot_browser_path`: Path to the Chrome binary
55
+ - `profile`: Path to the browser profile directory
56
+
57
+ ## API Reference
58
+
59
+ ### `BotBrowser.install(version = nil)`
60
+ Installs the Chrome browser for bot automation.
61
+ - `version`: Optional. Specific version to install. If not provided, installs the latest version.
62
+
63
+ ### `BotBrowser.uninstall`
64
+ Removes the installed browser and its configuration.
65
+
66
+ ### `BotBrowser.installed?`
67
+ Checks if the browser is installed.
68
+ - Returns: `true` if installed, `false` otherwise.
69
+
70
+ ### `BotBrowser.load`
71
+ Loads the BotBrowser configuration and sets up Chromate with the appropriate settings.
72
+ - Configures Chrome binary path
73
+ - Sets up browser profile
74
+ - Configures necessary Chrome flags for bot automation
data/docs/browser.md CHANGED
@@ -112,69 +112,35 @@ It will call `#xvfb_screenshot` private method if `xvfb` mode is `true`
112
112
 
113
113
  #### `#find_element(selector)`
114
114
 
115
- Finds a single element on the page using the specified CSS selector.
115
+ Finds a single element on the page using the specified CSS selector. Returns a specialized element class based on the element type:
116
116
 
117
117
  - **Parameters:**
118
118
  - `selector` (String): The CSS selector to locate the element.
119
119
 
120
120
  - **Returns:**
121
- - `Chromate::Element`: The found element.
121
+ - `Chromate::Elements::Select`: For `<select>` elements
122
+ - `Chromate::Elements::Option`: For `<option>` elements
123
+ - `Chromate::Elements::Radio`: For radio button inputs (`<input type="radio">`)
124
+ - `Chromate::Elements::Checkbox`: For checkbox inputs (`<input type="checkbox">`)
125
+ - `Chromate::Element`: For all other element types
122
126
 
123
- - **Example:**
124
- ```ruby
125
- element = browser.find_element('#my-element')
126
- puts element.text
127
- ```
128
-
129
- #### `#click_element(selector)`
130
-
131
- Finds an element by selector and clicks it.
127
+ Each specialized element type provides specific methods for interacting with that type of element. For example:
132
128
 
133
- - **Parameters:**
134
- - `selector` (String): The CSS selector of the element to click.
135
-
136
- - **Example:**
137
- ```ruby
138
- browser.click_element('#submit-button')
139
- ```
140
-
141
- #### `#hover_element(selector)`
142
-
143
- Finds an element by selector and hovers over it.
144
-
145
- - **Parameters:**
146
- - `selector` (String): The CSS selector of the element to hover.
147
-
148
- - **Example:**
149
- ```ruby
150
- browser.hover_element('#hover-target')
151
- ```
152
-
153
- #### `#type_text(selector, text)`
154
-
155
- Finds an element by selector and types the specified text into it.
156
-
157
- - **Parameters:**
158
- - `selector` (String): The CSS selector of the element.
159
- - `text` (String): The text to type into the element.
160
-
161
- - **Example:**
162
- ```ruby
163
- browser.type_text('#input-field', 'Hello, Chromate!')
164
- ```
165
-
166
- #### `#select_option(selector, option)`
129
+ ```ruby
130
+ # Working with radio buttons
131
+ radio = browser.find_element('input[type="radio"]')
132
+ radio.check if !radio.checked?
167
133
 
168
- Selects an option from a dropdown element.
134
+ # Working with checkboxes
135
+ checkbox = browser.find_element('input[type="checkbox"]')
136
+ checkbox.toggle
169
137
 
170
- - **Parameters:**
171
- - `selector` (String): The CSS selector of the dropdown element.
172
- - `option` (String): The value of the option to select.
138
+ # Working with select elements
139
+ select = browser.find_element('select#country')
140
+ select.select_option('France')
141
+ ```
173
142
 
174
- - **Example:**
175
- ```ruby
176
- browser.select_option('#dropdown', 'option2')
177
- ```
143
+ See the [Element documentation](element.md) for more details about specialized elements.
178
144
 
179
145
  #### `#evaluate_script(script)`
180
146
 
@@ -216,5 +182,4 @@ browser.navigate_to('https://example.com')
216
182
  browser.screenshot('example.png')
217
183
  element = browser.find_element('#main-header')
218
184
  puts element.text
219
- browser.stop
220
- ```
185
+ browser.stop
data/docs/client.md ADDED
@@ -0,0 +1,126 @@
1
+ # Client
2
+
3
+ The `Chromate::Client` class is responsible for managing WebSocket connections to Chrome DevTools Protocol (CDP). It handles communication between the Chromate library and the Chrome browser, including message sending, receiving, and event handling.
4
+
5
+ ### Initialization
6
+
7
+ ```ruby
8
+ client = Chromate::Client.new(browser)
9
+ ```
10
+
11
+ - **Parameters:**
12
+ - `browser` (Chromate::Browser): The browser instance to connect to.
13
+
14
+ ### Public Methods
15
+
16
+ #### `#start`
17
+
18
+ Establishes the WebSocket connection to Chrome DevTools Protocol and sets up event handlers.
19
+
20
+ - **Returns:**
21
+ - `self`: Returns the client instance for method chaining.
22
+
23
+ - **Example:**
24
+ ```ruby
25
+ client.start
26
+ ```
27
+
28
+ #### `#stop`
29
+
30
+ Closes the WebSocket connection.
31
+
32
+ - **Returns:**
33
+ - `self`: Returns the client instance for method chaining.
34
+
35
+ - **Example:**
36
+ ```ruby
37
+ client.stop
38
+ ```
39
+
40
+ #### `#send_message(method, params = {})`
41
+
42
+ Sends a message to Chrome DevTools Protocol and waits for the response.
43
+
44
+ - **Parameters:**
45
+ - `method` (String): The CDP method to call.
46
+ - `params` (Hash, optional): Parameters for the CDP method.
47
+
48
+ - **Returns:**
49
+ - `Hash`: The response from Chrome DevTools Protocol.
50
+
51
+ - **Example:**
52
+ ```ruby
53
+ result = client.send_message('DOM.getDocument')
54
+ ```
55
+
56
+ #### `#reconnect`
57
+
58
+ Reestablishes the WebSocket connection if it was lost.
59
+
60
+ - **Returns:**
61
+ - `self`: Returns the client instance for method chaining.
62
+
63
+ - **Example:**
64
+ ```ruby
65
+ client.reconnect
66
+ ```
67
+
68
+ #### `#on_message`
69
+
70
+ Subscribes to WebSocket messages. Allows different parts of the application to listen for CDP events.
71
+
72
+ - **Parameters:**
73
+ - `&block` (Block): The block to execute when a message is received.
74
+
75
+ - **Example:**
76
+ ```ruby
77
+ client.on_message do |message|
78
+ puts "Received message: #{message}"
79
+ end
80
+ ```
81
+
82
+ ### Class Methods
83
+
84
+ #### `.listeners`
85
+
86
+ Returns the array of registered message listeners.
87
+
88
+ - **Returns:**
89
+ - `Array<Proc>`: The array of listener blocks.
90
+
91
+ ### Event Handling
92
+
93
+ The client automatically handles several WebSocket events:
94
+
95
+ - `:message`: Processes incoming CDP messages and notifies listeners
96
+ - `:open`: Logs successful connection
97
+ - `:error`: Logs WebSocket errors
98
+ - `:close`: Logs connection closure
99
+
100
+ ### Error Handling
101
+
102
+ The client includes automatic reconnection logic when message sending fails:
103
+
104
+ - Attempts to reconnect to the WebSocket
105
+ - Retries the failed message
106
+ - Logs errors and debug information through `Chromate::CLogger`
107
+
108
+ ### Example Usage
109
+
110
+ ```ruby
111
+ browser = Chromate::Browser.new
112
+ client = Chromate::Client.new(browser)
113
+
114
+ client.start
115
+
116
+ # Send a CDP command
117
+ result = client.send_message('DOM.getDocument')
118
+
119
+ # Listen for specific events
120
+ client.on_message do |msg|
121
+ puts msg if msg['method'] == 'DOM.documentUpdated'
122
+ end
123
+
124
+ # Clean up
125
+ client.stop
126
+ ```
data/docs/element.md CHANGED
@@ -15,6 +15,43 @@ element = Chromate::Element.new(selector, client, node_id: nil, object_id: nil,
15
15
  - `object_id` (String, optional): The object ID of the element.
16
16
  - `root_id` (Integer, optional): The root node ID of the document.
17
17
 
18
+ ### Attributes
19
+
20
+ #### `#selector`
21
+
22
+ Returns the CSS selector used to locate the element.
23
+
24
+ - **Returns:**
25
+ - `String`: The CSS selector.
26
+
27
+ #### `#client`
28
+
29
+ Returns the CDP client instance used to communicate with the browser.
30
+
31
+ - **Returns:**
32
+ - `Chromate::Client`: The CDP client instance.
33
+
34
+ #### `#root_id`
35
+
36
+ Returns the root node ID of the document.
37
+
38
+ - **Returns:**
39
+ - `Integer`: The root node ID.
40
+
41
+ #### `#object_id`
42
+
43
+ Returns the object ID of the element.
44
+
45
+ - **Returns:**
46
+ - `String`: The object ID.
47
+
48
+ #### `#node_id`
49
+
50
+ Returns the node ID of the element.
51
+
52
+ - **Returns:**
53
+ - `Integer`: The node ID.
54
+
18
55
  ### Public Methods
19
56
 
20
57
  #### `#mouse`
@@ -74,6 +111,19 @@ Returns a hash of the element's attributes.
74
111
  puts "Element attributes: #{attributes}"
75
112
  ```
76
113
 
114
+ #### `#tag_name`
115
+
116
+ Gets the HTML tag name of the element in lowercase.
117
+
118
+ - **Returns:**
119
+ - `String`: The HTML tag name.
120
+
121
+ - **Example:**
122
+ ```ruby
123
+ tag = element.tag_name
124
+ puts "Tag name: #{tag}"
125
+ ```
126
+
77
127
  #### `#set_attribute(name, value)`
78
128
 
79
129
  Sets an attribute on the element.
@@ -283,7 +333,33 @@ Finds all child elements inside the shadow root using the given selector.
283
333
  shadow_elements.each { |el| puts el.text }
284
334
  ```
285
335
 
336
+ #### `#value`
337
+
338
+ Gets the value of the element.
339
+
340
+ - **Returns:**
341
+ - `String`: The element's value.
342
+
343
+ - **Example:**
344
+ ```ruby
345
+ value = element.value
346
+ puts "Element value: #{value}"
347
+ ```
348
+
286
349
  ### Exceptions
287
350
 
288
351
  - `NotFoundError`: Raised when an element cannot be found with the given selector.
289
- - `InvalidSelectorError`: Raised when the selector cannot resolve to a valid element.
352
+ - `InvalidSelectorError`: Raised when the selector cannot resolve to a valid element.
353
+
354
+ ## Specialized Elements
355
+
356
+ Chromate provides specialized element classes for specific HTML elements that have unique behaviors and methods. When using `find_element`, Chromate automatically returns the appropriate specialized element based on the element type.
357
+
358
+ ### Available Specialized Elements
359
+
360
+ - [Select Element](elements/select.md): For `<select>` elements
361
+ - [Option Element](elements/option.md): For `<option>` elements within select elements
362
+ - [Radio Element](elements/radio.md): For radio button inputs (`<input type="radio">`)
363
+ - [Checkbox Element](elements/checkbox.md): For checkbox inputs (`<input type="checkbox">`)
364
+
365
+ Each specialized element inherits from the base `Element` class and adds specific methods for interacting with that type of element. See the individual documentation files for details on the methods available for each element type.
@@ -0,0 +1,69 @@
1
+ # Checkbox Element
2
+
3
+ The `Chromate::Elements::Checkbox` class represents a checkbox input element in the browser. It extends the base `Element` class with specific functionality for checkboxes.
4
+
5
+ ### Initialization
6
+
7
+ ```ruby
8
+ checkbox = Chromate::Elements::Checkbox.new(selector, client, **options)
9
+ ```
10
+
11
+ - **Parameters:**
12
+ - `selector` (String): The CSS selector used to locate the checkbox.
13
+ - `client` (Chromate::Client): An instance of the CDP client.
14
+ - `options` (Hash): Additional options passed to the Element constructor.
15
+ - `object_id` (String): Optional. The object ID of a pre-searched element.
16
+ - `node_id` (Integer): Optional. The node ID of a pre-searched element.
17
+ - `root_id` (Integer): Optional. The root ID of a pre-searched element.
18
+
19
+ ### Public Methods
20
+
21
+ #### `#checked?`
22
+
23
+ Returns whether the checkbox is currently checked.
24
+
25
+ - **Returns:**
26
+ - `Boolean`: `true` if the checkbox is checked, `false` otherwise.
27
+
28
+ - **Example:**
29
+ ```ruby
30
+ if checkbox.checked?
31
+ puts "Checkbox is checked"
32
+ end
33
+ ```
34
+
35
+ #### `#check`
36
+
37
+ Checks the checkbox if it's not already checked.
38
+
39
+ - **Returns:**
40
+ - `self`: Returns the checkbox element for method chaining.
41
+
42
+ - **Example:**
43
+ ```ruby
44
+ checkbox.check
45
+ ```
46
+
47
+ #### `#uncheck`
48
+
49
+ Unchecks the checkbox if it's currently checked.
50
+
51
+ - **Returns:**
52
+ - `self`: Returns the checkbox element for method chaining.
53
+
54
+ - **Example:**
55
+ ```ruby
56
+ checkbox.uncheck
57
+ ```
58
+
59
+ #### `#toggle`
60
+
61
+ Toggles the checkbox state (checks if unchecked, unchecks if checked).
62
+
63
+ - **Returns:**
64
+ - `self`: Returns the checkbox element for method chaining.
65
+
66
+ - **Example:**
67
+ ```ruby
68
+ checkbox.toggle
69
+ ```
@@ -0,0 +1,57 @@
1
+ # Radio Element
2
+
3
+ The `Chromate::Elements::Radio` class represents a radio button input element in the browser. It extends the base `Element` class with specific functionality for radio buttons.
4
+
5
+ ### Initialization
6
+
7
+ ```ruby
8
+ radio = Chromate::Elements::Radio.new(selector, client, **options)
9
+ ```
10
+
11
+ - **Parameters:**
12
+ - `selector` (String): The CSS selector used to locate the radio button.
13
+ - `client` (Chromate::Client): An instance of the CDP client.
14
+ - `options` (Hash): Additional options passed to the Element constructor.
15
+ - `object_id` (String): Optional. The object ID of a pre-searched element.
16
+ - `node_id` (Integer): Optional. The node ID of a pre-searched element.
17
+ - `root_id` (Integer): Optional. The root ID of a pre-searched element.
18
+
19
+ ### Public Methods
20
+
21
+ #### `#checked?`
22
+
23
+ Returns whether the radio button is currently checked.
24
+
25
+ - **Returns:**
26
+ - `Boolean`: `true` if the radio button is checked, `false` otherwise.
27
+
28
+ - **Example:**
29
+ ```ruby
30
+ if radio.checked?
31
+ puts "Radio button is checked"
32
+ end
33
+ ```
34
+
35
+ #### `#check`
36
+
37
+ Checks the radio button if it's not already checked.
38
+
39
+ - **Returns:**
40
+ - `self`: Returns the radio element for method chaining.
41
+
42
+ - **Example:**
43
+ ```ruby
44
+ radio.check
45
+ ```
46
+
47
+ #### `#uncheck`
48
+
49
+ Unchecks the radio button if it's currently checked.
50
+
51
+ - **Returns:**
52
+ - `self`: Returns the radio element for method chaining.
53
+
54
+ - **Example:**
55
+ ```ruby
56
+ radio.uncheck
57
+ ```