vchrome 0.0.2__py3-none-any.whl → 0.0.4__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.
vchrome/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = '0.0.2'
1
+ __version__ = '0.0.4'
2
2
  __author__ = 'v'
3
3
  # ----------------------------------------------------------------------------------------------------
4
4
  _allowed = {'Chrome'}
@@ -810,6 +810,12 @@ def cdp_client(hostname, port, debug=False):
810
810
  if rdata['params'].get('targetInfo', {}).get('type') == 'service_worker':
811
811
  self.f.root._del_init_check()
812
812
  return
813
+ # TODO
814
+ # need to be compatible with workers in the future
815
+ if rdata['params'].get('targetInfo', {}).get('type') == 'worker':
816
+ # and rdata['params'].get('targetInfo', {}).get('title', '').startswith('blob'):
817
+ self.f.root._del_init_check()
818
+ return
813
819
  frameId = tinfo['targetId']
814
820
  sessionId = rdata['params']['sessionId']
815
821
  # self.f.cdp("Target.setAutoAttach", {
@@ -1198,6 +1204,16 @@ def cdp_client(hostname, port, debug=False):
1198
1204
  return self.f.element.visibility(self.objectId)
1199
1205
  def visible(self):
1200
1206
  d = self._view_info()
1207
+ # Page navigation destroys frames, invalidating the objectId's execution context and necessitating reacquisition.
1208
+ # only for ele(). on all need run wait_show() functions.
1209
+ if d.get('code') == -32000:
1210
+ f = getattr(self, 're_search', None)
1211
+ if f:
1212
+ e = f()
1213
+ if e:
1214
+ self.className = e.className
1215
+ self.objectId = e.objectId
1216
+ d = self._view_info()
1201
1217
  d['isCoverd'] = self._is_coverd()
1202
1218
  return d
1203
1219
  def info(self):
@@ -1254,6 +1270,7 @@ def cdp_client(hostname, port, debug=False):
1254
1270
  self.f = f
1255
1271
  self.attach(f)
1256
1272
  def attach(self, f):
1273
+ f.id = self.id
1257
1274
  f.ele = self.ele
1258
1275
  f.eles = self.eles
1259
1276
  f.xpath = self.xpath
@@ -1295,6 +1312,8 @@ def cdp_client(hostname, port, debug=False):
1295
1312
  if one and r: return r
1296
1313
  r.extend(sr.css(xf))
1297
1314
  return r
1315
+ def id(self, x, timeout=8, no_wait=False, all_frames=True):
1316
+ return self.ele('#'+ x, timeout=timeout, no_wait=no_wait, all_frames=all_frames)
1298
1317
  def ele(self, x, timeout=8, no_wait=False, all_frames=True):
1299
1318
  start = perf_counter()
1300
1319
  over_v_time = 2
@@ -1304,7 +1323,9 @@ def cdp_client(hostname, port, debug=False):
1304
1323
  if ctime - start > over_v_time: over_v_limit = True
1305
1324
  r = self._parse_x(x, all_frames, one=True, over_v_limit=over_v_limit)
1306
1325
  if ctime - start > over_v_time: over_v_limit = False
1307
- if r: return r[0]
1326
+ if r:
1327
+ r[0].re_search = lambda:self.ele(x)
1328
+ return r[0]
1308
1329
  if no_wait: return None
1309
1330
  if ctime - start > timeout:
1310
1331
  raise Exception('ele selecter timeout.')
@@ -1938,8 +1959,6 @@ def cdp_client(hostname, port, debug=False):
1938
1959
  self.element = ElementTools(self)
1939
1960
  self.browser = Browser(self)
1940
1961
  self.keyboard = Keyboard(self)
1941
- def id(self, i):
1942
- return self.ele('#'+ i)
1943
1962
  def press(self, key): self.cdp('Input.dispatchKeyEvent', self.keyboard._make_down(key))
1944
1963
  def release(self, key): self.cdp('Input.dispatchKeyEvent', self.keyboard._make_up(key))
1945
1964
  def close(self):
@@ -1,3 +1,3 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vchrome
3
- Version: 0.0.2
3
+ Version: 0.0.4
@@ -0,0 +1,5 @@
1
+ vchrome/__init__.py,sha256=jr8vqeslue8Qsks_Q8u8Hil5EGfJv9ZwTozKgWbF1A8,206643
2
+ vchrome-0.0.4.dist-info/METADATA,sha256=naCPRYBSrjbxNhwRaaccILJPsCYF5Re_Yh6mGtJnAfI,54
3
+ vchrome-0.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
+ vchrome-0.0.4.dist-info/top_level.txt,sha256=oB919Fa09PCy48Ptj8iy-1QUcvhEeY97MOR42281Fk0,8
5
+ vchrome-0.0.4.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- vchrome/__init__.py,sha256=GaD-j4I3g4mHbDtGiCd8-5M7iXKaC7CWJiXqJH_XXyk,205606
2
- vchrome-0.0.2.dist-info/METADATA,sha256=irZzBMagQl2VCh9fQTf-sLyWJOLcc2f0P4TWbvRpRBM,54
3
- vchrome-0.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
- vchrome-0.0.2.dist-info/top_level.txt,sha256=oB919Fa09PCy48Ptj8iy-1QUcvhEeY97MOR42281Fk0,8
5
- vchrome-0.0.2.dist-info/RECORD,,