You only need one browser. Open and attach the browser once before the loop. Do the extraction once to build the DataTable. After that, use the same attached browser inside the For Each Row loop to click appointments and fill data. Extraction should not be inside the loop, because the page reloads and causes the selector to reset. You extract first, then loop over the extracted data while staying in the same browser session.
I don’t understand how I can have a use browser activity before the loop, and then still use that same browser inside, if it started outside. Am I misunderstanding something?
Like this?
Read Range
Use Browser
├─ Extract appointments table (ListOfAppointments)
├─ For Each Row in DataTable (WedDt) ← outer loop
├─ assigned variables
├─ Use (ListOfAppointments) <—— Inner iteration
(For Each? find element? Get Text? While?) ???
├─ Calendar list: Click matching appointment
├─ Create progress note
├─ Use CurrentRow from WedDt for form input
├─ Save
└─ Navigate back to calendar
I don’t understand why I can’t use a dynamic select to do this:
Read Range
Use Browser
├─ For Each Row in DataTable (WedDt)
├─ assigned variables
├─ counter
├─ Appointments webpage:
├─ Click matching appointment
├─ dynamic selector using WedDt CurrentName
├─ Create progress note
├─ Save
└─ Navigate back to appointments
You only need one browser. Open it once, extract the appointment list first into a DataTable or list, then loop through that data. After each save and navigation back, the page reloads, so you must re-identify the appointment using a unique value like name or time, not index or counter. Dynamic selectors based on position won’t work reliably because the DOM resets each time.
Not exactly. You don’t need an inner loop over ListOfAppointments.
Correct structure is:
Use Browser
├─ Extract appointments table once into ListOfAppointments
├─ For Each Row in WedDt
│ ├─ Assign variables from CurrentRow
│ ├─ Click appointment by matching a unique value from ListOfAppointments (name/time)
│ ├─ Create progress note
│ ├─ Fill form using CurrentRow
│ ├─ Save
│ └─ Navigate back to calendar
I have multiple pages to go thru before returning to the schedules calendar though. Won’t having my extraction outside the loop, and/or leaving the calendar page before returning, reset my appointments? Is that what you mean by identifying unique value?
Yes,I guess this works even if you navigate away and come back. The extracted appointment list is only used as reference data and stays in memory. When the calendar reloads, you simply locate the appointment again using a unique value like name or time. You’re not relying on UI state, you’re re-identifying the appointment each time.
to identify each appointment, should I use get row item, lookup data table, or get text or attribute?
that data from the webpage is identical to my google sheet. I don’t understand why dynamic selectors aren’t working.
Use CurrentRow from the DataTable. No lookup needed. Identify the appointment on the page using Click or Find Element with the name or time from CurrentRow. Get Text or Get Attribute is only for initial extraction, not inside the loop.
Because the page reloads when you return. UiPath re-evaluates the selector and resolves it to the first matching element, even if the data matches your sheet. If the selector isn’t uniquely identifying one row, it will keep clicking the same appointment.
Is my extracted data table meant to be a list of string?
No. It should be a DataTable so you can store name, time, or ID together. A list of strings only works if one value is enough to uniquely identify the appointment.
It will be better if you provide screenshots if you are getting any errors that will help to answer better
For Each row In dt
If String.IsNullOrWhiteSpace(row(Status).ToString)
Then
row(“Status”).ToSting = “Completed”
Else
row(“Status”).ToSting = " "
Hi @DR_pathUser
- Read Range → store in
dt - For Each Row in dt
- If currentRow(“Status”).ToString.Trim = “”
- Do your process
- Set:
currentRow(“Status”) = “completed”
- After the loop
Write Range → writedtback to the same Excel sheet
For Each Row only updates the DataTable in memory.
Nothing changes in Excel until you use Write Range.