How to create a while loop that stops at the end of the pages

I want to create a while loop that stops at the end of the pages, like here:
screenshotrpa

I see two ways of doing it (looking to do this without vision):

  1. There is a hover stop sign above the next button when you’re at the last page. However, because of xpath, it continues “clicking” even though it’s not clickable. I’m not sure how to program in the hover stop sign (or what it’s actually called) without using vision.

  2. I can click on the pages button in the middle, scroll down and see the last page, then set the loop to run by that number. Problem is I don’t know how to do that “scroll down and see the last page” part.

Looking for help on either of the ways (or if there is a more clever way) - thank you!

Can you share url?
Need to check HTML to find xpath code

Unfortunately the URL is not public. I am sure I got the xpath code correctly though - I’m using an extension and my script could continue pressing “next” (it just won’t stop since it doesn’t realize that the last next button is “unclickable”)

you have to add code to exit loop if next button is not available

{
      "Command": "while_v2",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "storeText",
      "Target": "xpath=",
      "Value": "Next",
      "Description": ""
    },
    {
      "Command": "gotoIf_v2",
      "Target": "${Next} == \"#LNF\"",
      "Value": "ExitWhileLoop",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "label",
      "Target": "ExitWhileLoop",
      "Value": "",
      "Description": ""
    }

I tried running your script, replacing "Target": "xpath=", to "Target": "xpath=//*[@id=\"provider-mounter\"]/div/div[2]/div[2]/div/div[1]/div/div[2]/div/div[2]/div/div/div/div/div[2]/div/div[3]/div/div/div/div/div[3]/div/div[2]/button[2]" but it didn’t work - am I doing this correctly?

When I meant the next button is not available, I meant that xclick could still “click” it, it just won’t work and has a “stop” sign:
Screen Shot 2023-01-16 at 6.38.44 PM

Thanks again, really appreciate your help.

you have to find the code which exists if next page is available
or code which exists only if its last page

and use relative xpath

If the next page is available it shows

<button type="button" class="zp-button zp_zUY4r zp_MCSwB zp_xCVC9">

And when it’s unavailable it shows

<button type="button" class="zp-button zp_zUY4r zp_BAp0M zp_MCSwB zp_xCVC9" disabled="">

What function/variables should I use inside the while_v2 function?

try this:

{
      "Command": "while_v2",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "sourceSearch",
      "Target": "regex=disabled=\"\"",
      "Value": "Next",
      "Description": ""
    },
    {
      "Command": "gotoIf_v2",
      "Target": "Number(${Next}) ==1",
      "Value": "ExitWhileLoop",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "label",
      "Target": "ExitWhileLoop",
      "Value": "",
      "Description": ""
    }

Gotcha, thanks. Tried using your script, but it would complete the while loop straight away, even if it’s not at the end of the pages.

I tried doing a Do…RepeatIf instead, but can’t get the regex to work:

  "Commands": [
    {
      "Command": "do",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"provider-mounter\"]/div/div[2]/div[2]/div/div[1]/div/div[2]/div/div[2]/div/div/div/div/div[2]/div/div[3]/div/div/div/div/div[3]/div/div[2]/button[2]/div/span/img",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "repeatIf",
      "Target": "regex==disabled=\"\"",
      "Value": "",
      "Description": ""
    }
  ]

The error it gives me is:

[info]
Executing:  | repeatIf | regex==disabled="" |  | 
[error]
Line 3: Assigning to rvalue (1:0)

Both regex!=disabled="" and regex==disabled="" would give me the same error. Is there a way to fix this?

{
      "Command": "store",
      "Target": "0",
      "Value": "Next",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "Number(${Next})==0",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "sourceSearch",
      "Target": "regex=disabled=\"\">",
      "Value": "Next",
      "Description": ""
    },
    {
      "Command": "gotoIf_v2",
      "Target": "Number(${Next})==1",
      "Value": "ExitWhileLoop",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "label",
      "Target": "ExitWhileLoop",
      "Value": "",
      "Description": ""
    }

if checking next page is last step of while loop then can use this:

 {
      "Command": "store",
      "Target": "0",
      "Value": "Next",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "Number(${Next})==0",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "sourceSearch",
      "Target": "regex=disabled=\"\">",
      "Value": "Next",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }