Skip to content

Commit 671791c

Browse files
angiejonesNachoBritodhivakaranthonydoss7-engVishalBose7rpallavisharma
authored
Merge pull request #54 from angiejones/feat/new-tools
feat: add 14 new browser automation tools Co-authored-by: NachoBrito <[email protected]> Co-authored-by: dhivakaranthonydoss7-eng <[email protected]> Co-authored-by: VishalBose7 <[email protected]> Co-authored-by: rpallavisharma <[email protected]>
2 parents 91daa20 + 906498b commit 671791c

8 files changed

Lines changed: 1000 additions & 4 deletions

File tree

README.md

Lines changed: 245 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,250 @@ None required
436436
```
437437

438438

439+
### clear_element
440+
Clears the content of an input or textarea element.
441+
442+
**Parameters:**
443+
| Parameter | Type | Required | Description |
444+
|-----------|------|----------|-------------|
445+
| by | string | Yes | Locator strategy (id, css, xpath, name, tag, class) |
446+
| value | string | Yes | Value for the locator strategy |
447+
448+
**Example:**
449+
```json
450+
{
451+
"tool": "clear_element",
452+
"parameters": {
453+
"by": "id",
454+
"value": "search-input"
455+
}
456+
}
457+
```
458+
459+
### get_element_attribute
460+
Gets the value of an attribute from an element.
461+
462+
**Parameters:**
463+
| Parameter | Type | Required | Description |
464+
|-----------|------|----------|-------------|
465+
| by | string | Yes | Locator strategy (id, css, xpath, name, tag, class) |
466+
| value | string | Yes | Value for the locator strategy |
467+
| attribute | string | Yes | Name of the attribute to retrieve |
468+
469+
**Example:**
470+
```json
471+
{
472+
"tool": "get_element_attribute",
473+
"parameters": {
474+
"by": "id",
475+
"value": "my-link",
476+
"attribute": "href"
477+
}
478+
}
479+
```
480+
481+
### scroll_to_element
482+
Scrolls the page to make an element visible.
483+
484+
**Parameters:**
485+
| Parameter | Type | Required | Description |
486+
|-----------|------|----------|-------------|
487+
| by | string | Yes | Locator strategy (id, css, xpath, name, tag, class) |
488+
| value | string | Yes | Value for the locator strategy |
489+
490+
**Example:**
491+
```json
492+
{
493+
"tool": "scroll_to_element",
494+
"parameters": {
495+
"by": "id",
496+
"value": "footer"
497+
}
498+
}
499+
```
500+
501+
### execute_script
502+
Executes JavaScript in the browser and returns the result.
503+
504+
**Parameters:**
505+
| Parameter | Type | Required | Description |
506+
|-----------|------|----------|-------------|
507+
| script | string | Yes | JavaScript code to execute |
508+
509+
**Example:**
510+
```json
511+
{
512+
"tool": "execute_script",
513+
"parameters": {
514+
"script": "return document.title;"
515+
}
516+
}
517+
```
518+
519+
### get_window_handles
520+
Returns a list of all window/tab handles in the current session.
521+
522+
**Parameters:**
523+
None required
524+
525+
**Example:**
526+
```json
527+
{
528+
"tool": "get_window_handles",
529+
"parameters": {}
530+
}
531+
```
532+
533+
### switch_to_window
534+
Switches focus to a specific window or tab by its handle.
535+
536+
**Parameters:**
537+
| Parameter | Type | Required | Description |
538+
|-----------|------|----------|-------------|
539+
| handle | string | Yes | The window handle to switch to |
540+
541+
**Example:**
542+
```json
543+
{
544+
"tool": "switch_to_window",
545+
"parameters": {
546+
"handle": "CDwindow-1234"
547+
}
548+
}
549+
```
550+
551+
### switch_to_latest_window
552+
Switches focus to the most recently opened window or tab.
553+
554+
**Parameters:**
555+
None required
556+
557+
**Example:**
558+
```json
559+
{
560+
"tool": "switch_to_latest_window",
561+
"parameters": {}
562+
}
563+
```
564+
565+
### close_current_window
566+
Closes the current window/tab and switches back to the previous one.
567+
568+
**Parameters:**
569+
None required
570+
571+
**Example:**
572+
```json
573+
{
574+
"tool": "close_current_window",
575+
"parameters": {}
576+
}
577+
```
578+
579+
### switch_to_frame
580+
Switches focus to an iframe within the page.
581+
582+
**Parameters:**
583+
| Parameter | Type | Required | Description |
584+
|-----------|------|----------|-------------|
585+
| by | string | No | Locator strategy (id, css, xpath, name, tag, class) |
586+
| value | string | No | Value for the locator strategy |
587+
| index | number | No | Frame index (0-based) |
588+
589+
Provide either `by`/`value` to locate the frame by element, or `index` to switch by position. Omit all parameters to switch to the parent frame.
590+
591+
**Example:**
592+
```json
593+
{
594+
"tool": "switch_to_frame",
595+
"parameters": {
596+
"by": "id",
597+
"value": "my-iframe"
598+
}
599+
}
600+
```
601+
602+
### switch_to_default_content
603+
Switches focus back to the main page from an iframe.
604+
605+
**Parameters:**
606+
None required
607+
608+
**Example:**
609+
```json
610+
{
611+
"tool": "switch_to_default_content",
612+
"parameters": {}
613+
}
614+
```
615+
616+
### accept_alert
617+
Accepts (clicks OK on) a browser alert, confirm, or prompt dialog.
618+
619+
**Parameters:**
620+
| Parameter | Type | Required | Description |
621+
|-----------|------|----------|-------------|
622+
| timeout | number | No | Max wait time in ms (default: 5000) |
623+
624+
**Example:**
625+
```json
626+
{
627+
"tool": "accept_alert",
628+
"parameters": {}
629+
}
630+
```
631+
632+
### dismiss_alert
633+
Dismisses (clicks Cancel on) a browser alert or confirm dialog.
634+
635+
**Parameters:**
636+
| Parameter | Type | Required | Description |
637+
|-----------|------|----------|-------------|
638+
| timeout | number | No | Max wait time in ms (default: 5000) |
639+
640+
**Example:**
641+
```json
642+
{
643+
"tool": "dismiss_alert",
644+
"parameters": {}
645+
}
646+
```
647+
648+
### get_alert_text
649+
Gets the text content of a browser alert, confirm, or prompt dialog.
650+
651+
**Parameters:**
652+
| Parameter | Type | Required | Description |
653+
|-----------|------|----------|-------------|
654+
| timeout | number | No | Max wait time in ms (default: 5000) |
655+
656+
**Example:**
657+
```json
658+
{
659+
"tool": "get_alert_text",
660+
"parameters": {}
661+
}
662+
```
663+
664+
### send_alert_text
665+
Types text into a browser prompt dialog and accepts it.
666+
667+
**Parameters:**
668+
| Parameter | Type | Required | Description |
669+
|-----------|------|----------|-------------|
670+
| text | string | Yes | Text to type into the prompt |
671+
| timeout | number | No | Max wait time in ms (default: 5000) |
672+
673+
**Example:**
674+
```json
675+
{
676+
"tool": "send_alert_text",
677+
"parameters": {
678+
"text": "my input"
679+
}
680+
}
681+
```
682+
439683
## License
440684

441-
MIT
685+
MIT

0 commit comments

Comments
 (0)