simplex 1.2.65__py3-none-any.whl → 1.2.70__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.

Potentially problematic release.


This version of simplex might be problematic. Click here for more details.

simplex/simplex.py CHANGED
@@ -25,8 +25,53 @@ except ImportError:
25
25
  ImportWarning
26
26
  )
27
27
 
28
- BASE_URL = "https://simplex-dev--api-server-and-container-service-fastapi-app.modal.run"
29
- # BASE_URL = "https://api.simplex.sh"
28
+ BASE_URL = "https://api.simplex.sh"
29
+
30
+ class Playwright:
31
+ def __init__(self, simplex_instance):
32
+ self.simplex = simplex_instance
33
+
34
+ def click(self, locator: str, locator_type: str, exact: Optional[bool] = False,
35
+ element_index: Optional[str] = None, nth_index: Optional[int] = None,
36
+ locator_options: Optional[dict] = None):
37
+
38
+ if element_index and element_index not in ["first", "last", "nth"]:
39
+ raise ValueError("element_index must be 'first', 'last', or 'nth'")
40
+
41
+ if element_index=="nth" and not nth_index:
42
+ raise ValueError("nth_index is required when element_index is 'nth'")
43
+
44
+ data = {
45
+ 'session_id': self.simplex.session_id,
46
+ 'locator': locator,
47
+ 'locator_type': locator_type,
48
+ }
49
+
50
+ if element_index:
51
+ data['element_index'] = element_index
52
+ data['nth_index'] = nth_index
53
+
54
+ if exact:
55
+ data['exact'] = exact
56
+
57
+ if locator_options:
58
+ data['locator_options'] = json.dumps(locator_options)
59
+
60
+ response = requests.post(
61
+ f"{BASE_URL}/playwright/click",
62
+ headers={
63
+ 'x-api-key': self.simplex.api_key
64
+ },
65
+ data=data
66
+ )
67
+
68
+ if 'succeeded' not in response.json():
69
+ raise ValueError(f"It looks like the click action with playwright failed to return a response. Did you set your api_key when creating the Simplex class?")
70
+
71
+ if "succeeded" in response.json():
72
+ return
73
+ else:
74
+ raise ValueError(f"Failed to click element: {response.json()['error']}")
30
75
 
31
76
  class Simplex:
32
77
  def __init__(self, api_key: str):
@@ -147,7 +192,6 @@ class Simplex:
147
192
  },
148
193
  data=data
149
194
  )
150
-
151
195
  if 'succeeded' not in response.json():
152
196
  raise ValueError(f"It looks like the goto action failed to return a response. Did you set your api_key when creating the Simplex class?")
153
197
 
@@ -155,6 +199,7 @@ class Simplex:
155
199
  return
156
200
  else:
157
201
  raise ValueError(f"Failed to goto url: {response.json()['error']}")
202
+
158
203
 
159
204
  def click(self, element_description: str, cdp_url: str = None):
160
205
  if not element_description or not element_description.strip():
@@ -182,6 +227,35 @@ class Simplex:
182
227
  return response.json()["element_clicked"]
183
228
  else:
184
229
  raise ValueError(f"Failed to click element: {response.json()['error']}")
230
+
231
+ def select_dropdown_option(self, element_description: str, cdp_url: str = None):
232
+ if not element_description or not element_description.strip():
233
+ raise ValueError("element_description cannot be empty")
234
+ if not cdp_url and not self.session_id:
235
+ raise ValueError(f"Must call create_session before calling action select_from_dropdown with element_description='{element_description}'")
236
+
237
+ data = {'element_description': element_description}
238
+
239
+ if cdp_url:
240
+ data['cdp_url'] = cdp_url
241
+ else:
242
+ data['session_id'] = self.session_id
243
+
244
+
245
+ response = requests.post(
246
+ f"{BASE_URL}/select_dropdown_option",
247
+ headers={
248
+ 'x-api-key': self.api_key
249
+ },
250
+ data=data
251
+ )
252
+
253
+ if 'succeeded' not in response.json():
254
+ raise ValueError(f"It looks like the select_dropdown_option action failed to return a response. Did you set your api_key when creating the Simplex class?")
255
+ if response.json()["succeeded"]:
256
+ return response.json()["element_clicked"]
257
+ else:
258
+ raise ValueError(f"Failed to select dropdown option: {response.json()['error']}")
185
259
 
186
260
 
187
261
  def scroll_to_element(self, element_description: str, cdp_url: str = None):
@@ -726,6 +800,7 @@ class Simplex:
726
800
  },
727
801
  data=data
728
802
  )
803
+
729
804
  # Get filename from Content-Disposition header
730
805
  content_disposition = response.headers.get('Content-Disposition')
731
806
  if content_disposition:
@@ -742,7 +817,11 @@ class Simplex:
742
817
  except Exception:
743
818
  raise ValueError("File failed to be parsed from Content-Disposition header.")
744
819
  else:
745
- raise ValueError("No Content-Disposition header found. File was not downloaded.")
820
+ try:
821
+ raise ValueError(response.json()["error"])
822
+ except:
823
+ raise ValueError("No Content-Disposition header found. File was not downloaded.")
824
+
746
825
 
747
826
  # Check if response content is empty
748
827
  if len(response.content) == 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.65
3
+ Version: 1.2.70
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -18,7 +18,7 @@ Requires-Dist: requests
18
18
  Requires-Dist: python-dotenv
19
19
  Requires-Dist: click
20
20
  Provides-Extra: playwright
21
- Requires-Dist: playwright>=1.0.0; extra == "playwright"
21
+ Requires-Dist: rebrowser-playwright>=1.0.0; extra == "playwright"
22
22
  Dynamic: author
23
23
  Dynamic: author-email
24
24
  Dynamic: classifier
@@ -0,0 +1,11 @@
1
+ simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
2
+ simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
3
+ simplex/simplex.py,sha256=ANxoySLCicryPDkkXjxpNAVt2KQGPiURcbcjVqnkTq4,33850
4
+ simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
5
+ simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
6
+ simplex-1.2.70.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
7
+ simplex-1.2.70.dist-info/METADATA,sha256=GZzXInBUQRPReRBraW68Wms0n_eaZ_JpoFXG7yF2MBg,1055
8
+ simplex-1.2.70.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
+ simplex-1.2.70.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
10
+ simplex-1.2.70.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
11
+ simplex-1.2.70.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
2
- simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
3
- simplex/simplex.py,sha256=rWS3XpNjAgpLkj05VwZKAJzWMhJT-A5WKp1_x_e4sww,30887
4
- simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
5
- simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
6
- simplex-1.2.65.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
7
- simplex-1.2.65.dist-info/METADATA,sha256=XriIpgMHUdRrTMAioGI3sZIMtgh15w_b1TZig8C111M,1045
8
- simplex-1.2.65.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
- simplex-1.2.65.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
10
- simplex-1.2.65.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
11
- simplex-1.2.65.dist-info/RECORD,,