ChatGPT select last paragraph

The rule is easy: Whatever another RPA tool can do, UIV can do, too - but easier :slight_smile:

You were actually very close to the solution!

First we use to first use the CLICK command and the “Select” button get the raw XPath. Then, from the list of possible locators, select the easiest one. This video shows it:

Then, - and this was the missing step in your macro - we create a loop and increase the div[4] value by 2 each loop. That is all!

So here is the full ChatGPT web scraping automation with UI.Vision running:

Note that our automation is more robust than the Robomotion one you mentioned above. In the Robomotion video the person is using a hardcoded delay of 15 seconds to wait for the ChatGPT answer, but that will fail when the system is under load. We use computer vision (visualAssert) to wait for the “Regenerate” button to show. Only then we extract the text.

Source:

{
  "Name": "chatgpt",
  "CreationDate": "2022-12-23",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://chat.openai.com/chat",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "30",
      "Value": "!timeout_wait",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "2",
      "Value": "diffcounter",
      "Description": ""
    },
    {
      "Command": "times",
      "Target": "10",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "tell me a random joke",
      "Value": "q",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${!times}: Question = ${q}",
      "Value": "blue",
      "Description": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//textarea",
      "Value": "${q}",
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//form/div/div[2]/button",
      "Value": "",
      "Description": "button click"
    },
    {
      "Command": "visualAssert",
      "Target": "regen_button_dpi_168.png",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "comment",
      "Target": "click // xpath=//div[${diffcounter}]/div",
      "Value": "c",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=//div[4]/div",
      "Value": "testvar",
      "Description": "button click"
    },
    {
      "Command": "storeText",
      "Target": "xpath=//div[${diffcounter}]/div",
      "Value": "c",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${!times}: ChatGPT says: ${c}",
      "Value": "green",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return parseInt(${diffcounter}) +2 ;",
      "Value": "diffcounter",
      "Description": "Increment the variable by 2"
    },
    {
      "Command": "echo",
      "Target": "New Diffcounter: ${Diffcounter}",
      "Value": "pink",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}

PS: ChatGPT is an amazing tool. :100:

1 Like