vchrome 0.0.2__py3-none-any.whl → 0.0.3__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.3'
2
2
  __author__ = 'v'
3
3
  # ----------------------------------------------------------------------------------------------------
4
4
  _allowed = {'Chrome'}
@@ -1198,6 +1198,16 @@ def cdp_client(hostname, port, debug=False):
1198
1198
  return self.f.element.visibility(self.objectId)
1199
1199
  def visible(self):
1200
1200
  d = self._view_info()
1201
+ # Page navigation destroys frames, invalidating the objectId's execution context and necessitating reacquisition.
1202
+ # only for ele(). on all need run wait_show() functions.
1203
+ if d.get('code') == -32000:
1204
+ f = getattr(self, 're_search', None)
1205
+ if f:
1206
+ e = f()
1207
+ if e:
1208
+ self.className = e.className
1209
+ self.objectId = e.objectId
1210
+ d = self._view_info()
1201
1211
  d['isCoverd'] = self._is_coverd()
1202
1212
  return d
1203
1213
  def info(self):
@@ -1254,6 +1264,7 @@ def cdp_client(hostname, port, debug=False):
1254
1264
  self.f = f
1255
1265
  self.attach(f)
1256
1266
  def attach(self, f):
1267
+ f.id = self.id
1257
1268
  f.ele = self.ele
1258
1269
  f.eles = self.eles
1259
1270
  f.xpath = self.xpath
@@ -1295,6 +1306,8 @@ def cdp_client(hostname, port, debug=False):
1295
1306
  if one and r: return r
1296
1307
  r.extend(sr.css(xf))
1297
1308
  return r
1309
+ def id(self, x, timeout=8, no_wait=False, all_frames=True):
1310
+ return self.ele('#'+ x, timeout=timeout, no_wait=no_wait, all_frames=all_frames)
1298
1311
  def ele(self, x, timeout=8, no_wait=False, all_frames=True):
1299
1312
  start = perf_counter()
1300
1313
  over_v_time = 2
@@ -1304,7 +1317,9 @@ def cdp_client(hostname, port, debug=False):
1304
1317
  if ctime - start > over_v_time: over_v_limit = True
1305
1318
  r = self._parse_x(x, all_frames, one=True, over_v_limit=over_v_limit)
1306
1319
  if ctime - start > over_v_time: over_v_limit = False
1307
- if r: return r[0]
1320
+ if r:
1321
+ r[0].re_search = lambda:self.ele(x)
1322
+ return r[0]
1308
1323
  if no_wait: return None
1309
1324
  if ctime - start > timeout:
1310
1325
  raise Exception('ele selecter timeout.')
@@ -1938,8 +1953,6 @@ def cdp_client(hostname, port, debug=False):
1938
1953
  self.element = ElementTools(self)
1939
1954
  self.browser = Browser(self)
1940
1955
  self.keyboard = Keyboard(self)
1941
- def id(self, i):
1942
- return self.ele('#'+ i)
1943
1956
  def press(self, key): self.cdp('Input.dispatchKeyEvent', self.keyboard._make_down(key))
1944
1957
  def release(self, key): self.cdp('Input.dispatchKeyEvent', self.keyboard._make_up(key))
1945
1958
  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.3
@@ -0,0 +1,5 @@
1
+ vchrome/__init__.py,sha256=EJQjfA2gVhXOHKjJATTFr9ePDw-THC4DTMflWnAitck,206316
2
+ vchrome-0.0.3.dist-info/METADATA,sha256=AFIZUSrXsfq6ga97ItMe7CSflB5qxy28d0Di9Zqkhvc,54
3
+ vchrome-0.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
+ vchrome-0.0.3.dist-info/top_level.txt,sha256=oB919Fa09PCy48Ptj8iy-1QUcvhEeY97MOR42281Fk0,8
5
+ vchrome-0.0.3.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,,