How to continue this mathematical pattern?

I have 1000‘s of div‘s that need to be clicked and the order is the following code:

{
“Name”: “Test-2”,
“CreationDate”: “2024-6-12”,
“Commands”: [
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul/li[3]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul/li[4]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul/li[5]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul/li[6]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul/li[7]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul/li[8]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul/li[9]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul[2]/li/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul[2]/li[2]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul[2]/li[3]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul[2]/li[4]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul[2]/li[5]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul[2]/li[6]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul[2]/li[7]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul[2]/li[8]/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul[2]/li[9]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="t1103077807"]/ul[3]/li/a/div/div",
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: "xpath=//
[@id="t1103077807"]/ul[3]/li[2]/a/div/div”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//*[@id="t1103077807"]/ul[3]/li[3]/a/div/div”,
“Value”: “”,
“Description”: “”
},

It goes until:

{
“Command”: “click”,
“Target”: “xpath=//*[@id="t1103077807"]/ul[106]/li[3]/a/div/div”,
“Value”: “”,
“Description”: “”
},

I used ChatGPT to continue this code but it’s very slow, so i wonder if it’s possible to use some operators to continue this and also reduce the size of the source code.

Thanks a lot in advance!

1 Like
{
      "Command": "times",
      "Target": "105",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "${!times}",
      "Value": "x",
      "Description": ""
    },
    {
      "Command": "times",
      "Target": "9",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "${!times}",
      "Value": "y",
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//[@id=\"t1103077807\"]/ul[${x}]/li[${y}]/a/div/div",
      "Value": "red",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }

for 106
you can change loop and add condition or add 3 more clicks

1 Like