Browser Actions

There are five types of Bytebot BrowserAction types. These can be split into two categories: void actions (Click, AssignAttribute) which generated by Bytebot’s Act function and extract actions (CopyText, CopyAttribute, ExtractTable) which are generated by Bytebot’s Extract function. The actions vary in complexity.

Click Action

A Click action is executes clicking on a page element. It features two attributes:

  • type: “Click” (constant)
  • xpath: a xpath string that points to a specific element.
1[
2 {
3 type: "Click",
4 xpath: "/html/body/div[1]/div[2]/div[2]/button",
5 }
6]

When executed, this action will always return null.

CopyText Action

A CopyText action executes a read on an element’s innerText. It features two attributes:

  • type: “CopyText” (constant)
  • xpath: a xpath string that points to a specific element.
1[
2 {
3 type: "CopyText",
4 xpath: "/html/body/div[1]/div[2]/div[2]/button",
5 }
6]

When executed, the action will return a string. If the text content of the element is empty, it will return null.

CopyAttribute Action

A CopyAttribute action executes a read on a specific element’s attribute. It features three attributes:

  • type: “CopyAttribute” (constant)
  • xpath: a xpath string that points to a specific element.
  • attribute: a string that specifies the targeted attribute
1[
2 {
3 type: "CopyAttribute",
4 xpath: "/html/body/div[1]/div[2]/div[2]/button[1]",
5 attribute: "href",
6 }
7]

When executed, the action will return a string. If the attribute of the element is undefined, it will return null.

AssignAttribute Action

An AssignAttribute action executes a write operation on a specific element’s specified attribute. It is the only browser action that writes content. The AssignAttribute action includes five attributes:

  • type: “AssignAttribute” (constant)
  • xpath: a xpath string that points to a specific element.
  • attribute: a string that specifies the targeted attribute
  • value: the value that an attribute is set
1[
2 {
3 type: "AssignAttribute",
4 xpath: "/html/body/div[1]/div[2]/div[2]/button[1]",
5 attribute: "href",
6 value: "true",
7 }
8]

When executed, this action will always return null.

ExtractTable Action

An ExtractTable action executes a read operation on multiple elements that may have columnized data. ExtractTable is used to create an array of listed content The ExtractTable action includes three attributes:

  • type: “AssignAttribute” (constant)
  • xpath: a xpath string that points to a specific element.
  • rows: an array of column objects, each with a name (string) and an action (BrowserAction).
1 {
2 type: "ExtractTable",
3 xpath: "/html/body/div[1]/div[2]/div[2]/tr",
4 rows:[
5 [
6 {
7 name: "Name",
8 action: {
9 xpath: "/html/body/div[1]/div[2]/div[2]/tr[1]/td[1]",
10 type: "CopyText"
11 }
12 },
13 {
14 name: "Address",
15 action: {
16 xpath: "/html/body/div[1]/div[2]/div[2]/tr[1]/td[2]",
17 type: "CopyText"
18 }
19 },
20 {
21 name: "Link",
22 action: {
23 xpath: "/html/body/div[1]/div[2]/div[2]/tr[1]/td[3]/a",
24 type: "CopyAttribute",
25 attribute: "href"
26 }
27 }
28 ]
29
30 ...
31
32 ]
33 }

When executed, this action will return an array of Record<string,string|null>.