-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into feature/action-imp…
…lementation
- Loading branch information
Showing
21 changed files
with
437 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,62 @@ | ||
import { Tool, InputSchema, ExecutionContext } from "../../types/action.types"; | ||
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types'; | ||
|
||
/** | ||
* Element click | ||
*/ | ||
export class ElementClick implements Tool { | ||
export class ElementClick implements Tool<any, any> { | ||
name: string; | ||
description: string; | ||
input_schema: InputSchema; | ||
|
||
constructor() { | ||
this.name = "element_click"; | ||
this.description = "click element"; | ||
this.name = 'element_click'; | ||
this.description = 'click element'; | ||
this.input_schema = { | ||
type: "object", | ||
type: 'object', | ||
properties: { | ||
element: { | ||
type: "string", | ||
description: "Element title", | ||
type: 'string', | ||
description: 'Element title', | ||
}, | ||
}, | ||
required: ["element"], | ||
required: ['element'], | ||
}; | ||
} | ||
|
||
async execute(context: ExecutionContext, params: unknown): Promise<unknown> { | ||
if ( | ||
typeof params !== "object" || | ||
params === null || | ||
!("content" in params) | ||
) { | ||
throw new Error( | ||
'Invalid parameters. Expected an object with a "content" property.' | ||
async execute(context: ExecutionContext, params: any): Promise<any> { | ||
if (typeof params !== 'object' || params === null || !('content' in params)) { | ||
throw new Error('Invalid parameters. Expected an object with a "content" property.'); | ||
} | ||
// button, span, lable, a, img, input, textarea, strlen < 30 | ||
// TODO .... | ||
throw new Error('Not implemented'); | ||
} | ||
} | ||
|
||
function xpath(element: any) { | ||
return (function (element) { | ||
if (element.id !== '') { | ||
return '//*[@id=\"' + element.id + '\"]'; | ||
} | ||
if (element == document.body) { | ||
return '/html/' + element.tagName.toLowerCase(); | ||
} | ||
var ix = 1, | ||
siblings = element.parentNode.childNodes; | ||
for (var i = 0, l = siblings.length; i < l; i++) { | ||
var sibling = siblings[i]; | ||
if (sibling == element) { | ||
return ( | ||
arguments.callee(element.parentNode) + | ||
'/' + | ||
element.tagName.toLowerCase() + | ||
'[' + | ||
ix + | ||
']' | ||
); | ||
} else if (sibling.nodeType == 1 && sibling.tagName == element.tagName) { | ||
ix++; | ||
} | ||
// TODO .... | ||
throw new Error('Not implemented') | ||
} | ||
} | ||
})(arguments[0]); | ||
} |
Oops, something went wrong.