Action Types

CopyText Action

Return the text content of an Element

This type of action will be created by Bytebot when prompted to read the text content of an Element. For example, the prompts “get me the name of the first person in the list” or “extract the address of the company” will create this type of action.

Example:

1// On a page with a title
2const actions = await bytebot.extract(Text("The title of the page"), page);

Example of returned actions:

1[
2 {
3 type: "CopyText",
4 xpath: "/html/body/div[1]/div[2]/div[2]/h1",
5 }
6]

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

1const title = await bytebot.execute(actions, page)
2console.log(title) // 'The Title of the Page'