Spaces:
Running
Running
Commit ·
328cc17
1
Parent(s): a4aa4fd
Almost Done
Browse files
worker.py
CHANGED
|
@@ -141,18 +141,32 @@ class QuantumBot:
|
|
| 141 |
try:
|
| 142 |
self.micro_status(f"Searching for '{patient_name}'...")
|
| 143 |
search_box = WebDriverWait(self.driver, self.DEFAULT_TIMEOUT).until(EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='Search']")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
search_box.click(); time.sleep(0.5); search_box.clear(); time.sleep(0.5)
|
| 145 |
search_box.send_keys(patient_name)
|
| 146 |
|
| 147 |
-
#
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
self.micro_status("Opening transaction details...")
|
| 155 |
-
WebDriverWait(self.driver, self.DEFAULT_TIMEOUT).until(EC.element_to_be_clickable((By.XPATH, f"
|
| 156 |
WebDriverWait(self.driver, self.DEFAULT_TIMEOUT).until(EC.element_to_be_clickable((By.LINK_TEXT, "Transaction Detail"))).click()
|
| 157 |
self._wait_for_page_load()
|
| 158 |
self.micro_status("Adding to Vault...")
|
|
|
|
| 141 |
try:
|
| 142 |
self.micro_status(f"Searching for '{patient_name}'...")
|
| 143 |
search_box = WebDriverWait(self.driver, self.DEFAULT_TIMEOUT).until(EC.element_to_be_clickable((By.XPATH, "//input[@placeholder='Search']")))
|
| 144 |
+
|
| 145 |
+
# --- Definitive Search Fix ---
|
| 146 |
+
# 1. Get a reference to the current first row of the table.
|
| 147 |
+
try:
|
| 148 |
+
old_first_row = self.driver.find_element(By.XPATH, "//tbody/tr[1]")
|
| 149 |
+
except NoSuchElementException:
|
| 150 |
+
old_first_row = None # Handle case where table is initially empty
|
| 151 |
+
|
| 152 |
+
# 2. Type the search text.
|
| 153 |
search_box.click(); time.sleep(0.5); search_box.clear(); time.sleep(0.5)
|
| 154 |
search_box.send_keys(patient_name)
|
| 155 |
|
| 156 |
+
# 3. Wait for the old row to disappear (become stale). This is the key.
|
| 157 |
+
if old_first_row:
|
| 158 |
+
self.micro_status("Waiting for search results to update...")
|
| 159 |
+
WebDriverWait(self.driver, 15).until(EC.staleness_of(old_first_row))
|
| 160 |
+
else:
|
| 161 |
+
time.sleep(2) # If no old row, just pause briefly for results to appear
|
| 162 |
|
| 163 |
+
# 4. Now, confidently wait for the new row to appear.
|
| 164 |
+
self.micro_status("Waiting for new search result row to appear...")
|
| 165 |
+
new_row_xpath = f"//tr[contains(., \"{patient_name}\")]"
|
| 166 |
+
WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH, new_row_xpath)))
|
| 167 |
+
|
| 168 |
self.micro_status("Opening transaction details...")
|
| 169 |
+
WebDriverWait(self.driver, self.DEFAULT_TIMEOUT).until(EC.element_to_be_clickable((By.XPATH, f"{new_row_xpath}//button[@data-v-b6b33fa0]"))).click()
|
| 170 |
WebDriverWait(self.driver, self.DEFAULT_TIMEOUT).until(EC.element_to_be_clickable((By.LINK_TEXT, "Transaction Detail"))).click()
|
| 171 |
self._wait_for_page_load()
|
| 172 |
self.micro_status("Adding to Vault...")
|