parsagon 0.14.7__py3-none-any.whl → 0.14.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
parsagon/executor.py CHANGED
@@ -212,6 +212,11 @@ class Executor:
212
212
  elem.getparent().remove(elem)
213
213
 
214
214
  # Remove invisible elements
215
+ id_to_elem = {}
216
+ for elem in root.iter():
217
+ elem_id = elem.get("data-psgn-id")
218
+ if elem_id:
219
+ id_to_elem[elem_id] = elem
215
220
  visible_elem_ids = set(
216
221
  driver.execute_script(
217
222
  "return Array.from(document.getElementsByTagName('*')).filter((elem) => { const style = getComputedStyle(elem); return style.opacity > 0.1 && style.display !== 'none' && style.visibility === 'visible' && elem.offsetWidth && elem.offsetHeight && elem.getClientRects().length }).map((elem) => elem.getAttribute('data-psgn-id'))"
@@ -220,15 +225,12 @@ class Executor:
220
225
  max_elem_id = self.max_elem_ids[self.driver.current_window_handle]
221
226
  with Progress() as progress:
222
227
  for elem_id in progress.track(range(max_elem_id), description="[green]Analyzing page"):
223
- is_visible = str(elem_id) in visible_elem_ids
224
- if not is_visible:
225
- try:
226
- lxml_elem = root.xpath(f'//*[@data-psgn-id="{elem_id}"]')[0]
227
- parent = lxml_elem.getparent()
228
- if parent is not None:
229
- parent.remove(lxml_elem)
230
- except IndexError:
231
- continue
228
+ elem_id = str(elem_id)
229
+ if elem_id in id_to_elem and elem_id not in visible_elem_ids:
230
+ lxml_elem = id_to_elem[elem_id]
231
+ parent = lxml_elem.getparent()
232
+ if parent is not None:
233
+ parent.remove(lxml_elem)
232
234
 
233
235
  return lxml.html.tostring(root).decode()
234
236
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: parsagon
3
- Version: 0.14.7
3
+ Version: 0.14.8
4
4
  Summary: Allows you to create browser automations with natural language
5
5
  Author-email: Sandy Suh <sandy@parsagon.io>
6
6
  Project-URL: Homepage, https://parsagon.io
@@ -5,7 +5,7 @@ parsagon/create.py,sha256=UiX6ffLPw2zF4atQxHFKBXpnlX05G1HHSn7Xi4K7tBM,3921
5
5
  parsagon/custom_function.py,sha256=oEj28qItaHUnsvLIHD7kg5QL3J3aO6rW6xKKP-H-Drs,770
6
6
  parsagon/edit.py,sha256=aLeAcp1hFHm29qh6do21cfYykK76CsHC4tc9Uh2_2bk,3006
7
7
  parsagon/exceptions.py,sha256=tG1vnpmUN1GdJ1GSpe1MaWH3zWmFLZCwtOfEGu8qPP0,910
8
- parsagon/executor.py,sha256=umsIkUtWxNU1VmO8DCFb0lUIZ7w_2LONfa5g34MuHGw,24130
8
+ parsagon/executor.py,sha256=u5cJ75tv4eGXHqi5kvwdVsKX7v_sK3ecReB3heQKThw,24179
9
9
  parsagon/gui_entry.py,sha256=bqG9K0CArXWWwDGoT8aV17YLNM8MfjSf6SJ_B3QbNeA,671
10
10
  parsagon/highlights.js,sha256=2UDfUApblU9xtGgTLCq4X7rHRV0wcqDSSFZPmJS6fJg,16643
11
11
  parsagon/main.py,sha256=3BskD1QPqDOfSwLGJBIn0-npNxRy5KZUtKIVNAKYwtA,9349
@@ -25,8 +25,8 @@ parsagon/tests/test_invalid_args.py,sha256=TAFdHGy92lUxjljPrtODOuEGVss6rn-F5GvEK
25
25
  parsagon/tests/test_pipeline_operations.py,sha256=aEwZNtIwOl9X7jdLDLB4YEdgMp7_x8PXCINAE7RT4NY,805
26
26
  parsagon/tests/test_print.py,sha256=BG7f55YDBoL0S7k291-so_Gje_hUAQOkB-jh-bEYsJY,198
27
27
  parsagon/tests/test_secrets.py,sha256=Ctsscl2tmMTZcFAy5dnyqUlgTov2UharZgLpbRCLdEg,2662
28
- parsagon-0.14.7.dist-info/METADATA,sha256=5GBklSqHzotEcLVAxGkAi5rkLFMyQd5_Kx3vvxK9NHQ,2431
29
- parsagon-0.14.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
30
- parsagon-0.14.7.dist-info/entry_points.txt,sha256=I1UlPUb4oY2k9idkI8kvdkEcrjKGRSOl5pMbA6uu6kw,48
31
- parsagon-0.14.7.dist-info/top_level.txt,sha256=ih5uYQzW4qjhRKppys-WiHLIbXVZ99YdqDcfAtlcQwk,9
32
- parsagon-0.14.7.dist-info/RECORD,,
28
+ parsagon-0.14.8.dist-info/METADATA,sha256=MXyhzpzhKURpirSGKw7blpCGu60WHQmQO6bhcpjYK74,2431
29
+ parsagon-0.14.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
30
+ parsagon-0.14.8.dist-info/entry_points.txt,sha256=I1UlPUb4oY2k9idkI8kvdkEcrjKGRSOl5pMbA6uu6kw,48
31
+ parsagon-0.14.8.dist-info/top_level.txt,sha256=ih5uYQzW4qjhRKppys-WiHLIbXVZ99YdqDcfAtlcQwk,9
32
+ parsagon-0.14.8.dist-info/RECORD,,