vchrome 0.1.7__py3-none-any.whl → 0.1.9__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 +22 -17
- {vchrome-0.1.7.dist-info → vchrome-0.1.9.dist-info}/METADATA +1 -1
- vchrome-0.1.9.dist-info/RECORD +6 -0
- vchrome-0.1.7.dist-info/RECORD +0 -6
- {vchrome-0.1.7.dist-info → vchrome-0.1.9.dist-info}/WHEEL +0 -0
- {vchrome-0.1.7.dist-info → vchrome-0.1.9.dist-info}/top_level.txt +0 -0
vchrome/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = '0.1.
|
|
1
|
+
__version__ = '0.1.9'
|
|
2
2
|
__author__ = 'v'
|
|
3
3
|
# ----------------------------------------------------------------------------------------------------
|
|
4
4
|
_allowed = {'Chrome'}
|
|
@@ -908,7 +908,7 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
908
908
|
"waitForDebuggerOnStart": True,
|
|
909
909
|
"flatten": True,
|
|
910
910
|
}, sessionId=sessionId)
|
|
911
|
-
self.f.cdp('DOM.enable', sessionId=sessionId)
|
|
911
|
+
# self.f.cdp('DOM.enable', sessionId=sessionId) # only call api. not listen events, no need enable.
|
|
912
912
|
self.f.cdp('Page.enable', sessionId=sessionId)
|
|
913
913
|
if runtimeEnable: self.f.cdp('Runtime.enable', sessionId=sessionId)
|
|
914
914
|
self.f.add_sniff_session(sessionId)
|
|
@@ -1072,16 +1072,16 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
1072
1072
|
return self.f.cdp('DOM.getBoxModel', {'objectId': self.objectId})
|
|
1073
1073
|
def __repr__(self):
|
|
1074
1074
|
return '<DOM:[{}] [{}]>'.format(self.className, self.objectId)
|
|
1075
|
-
def clear(self, delay_uptime=0.15, timegap=0.01):
|
|
1076
|
-
self.wait_show()
|
|
1075
|
+
def clear(self, delay_uptime=0.15, timegap=0.01, timeout=15):
|
|
1076
|
+
self.wait_show(timeout)
|
|
1077
1077
|
self.f.cdp('DOM.focus', {"objectId": self.objectId})
|
|
1078
1078
|
clear_ents = self.f.rootf.make_clear()
|
|
1079
1079
|
for kdn in clear_ents[:2]: time.sleep(timegap); self.f.cdp('Input.dispatchKeyEvent', kdn)
|
|
1080
1080
|
time.sleep(delay_uptime)
|
|
1081
1081
|
for kup in clear_ents[2:4]: time.sleep(timegap); self.f.cdp('Input.dispatchKeyEvent', kup)
|
|
1082
1082
|
for delt in clear_ents[4:]: time.sleep(timegap); self.f.cdp('Input.dispatchKeyEvent', delt)
|
|
1083
|
-
def input(self, str, delay_time=0.02, delay_uptime=0.15, random_gap=0.01):
|
|
1084
|
-
self.wait_show()
|
|
1083
|
+
def input(self, str, delay_time=0.02, delay_uptime=0.15, random_gap=0.01, timeout=15):
|
|
1084
|
+
self.wait_show(timeout)
|
|
1085
1085
|
self.f.cdp('DOM.focus', {"objectId": self.objectId})
|
|
1086
1086
|
for kdn, kup in self.f.rootf.make_input_events(str):
|
|
1087
1087
|
if kdn == 'insertText':
|
|
@@ -1112,8 +1112,8 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
1112
1112
|
return _x, _y
|
|
1113
1113
|
def _set_in_view(self):
|
|
1114
1114
|
self.f.cdp('DOM.scrollIntoViewIfNeeded', {"objectId": self.objectId})
|
|
1115
|
-
def click(self, x=1, y=2, zero='center', button='left', count=1):
|
|
1116
|
-
self.wait_show()
|
|
1115
|
+
def click(self, x=1, y=2, zero='center', button='left', count=1, timeout=15):
|
|
1116
|
+
self.wait_show(timeout)
|
|
1117
1117
|
self._set_in_view()
|
|
1118
1118
|
_x, _y = self._get_xy(x, y, zero)
|
|
1119
1119
|
self.f.cdp('Input.dispatchMouseEvent',{"buttons":0,"type":"mouseMoved","x":_x,"y":_y,"button":"none","clickCount":0})
|
|
@@ -1146,7 +1146,7 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
1146
1146
|
y += points[i][1]*B
|
|
1147
1147
|
r.append([x, y])
|
|
1148
1148
|
return r
|
|
1149
|
-
def wait_show(self, timeout=
|
|
1149
|
+
def wait_show(self, timeout=15, pretime=0.1):
|
|
1150
1150
|
start = perf_counter()
|
|
1151
1151
|
count, acount = 0, 0
|
|
1152
1152
|
px, py = 0, 0
|
|
@@ -1162,13 +1162,14 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
1162
1162
|
px, py = x, y
|
|
1163
1163
|
if count > 1 or acount > 5:
|
|
1164
1164
|
break
|
|
1165
|
-
|
|
1166
|
-
|
|
1165
|
+
else:
|
|
1166
|
+
if perf_counter() - start > timeout:
|
|
1167
|
+
raise Exception('wait show over time.')
|
|
1167
1168
|
time.sleep(0.08)
|
|
1168
1169
|
if pretime:
|
|
1169
1170
|
time.sleep(pretime) # When the component appears, the event might not have been attached yet. Please wait a moment.
|
|
1170
|
-
def drag(self, x=1, y=2, zero='center', button='left', count=1):
|
|
1171
|
-
self.wait_show()
|
|
1171
|
+
def drag(self, x=1, y=2, zero='center', button='left', count=1, timeout=15):
|
|
1172
|
+
self.wait_show(timeout)
|
|
1172
1173
|
self._set_in_view()
|
|
1173
1174
|
x, y = self._get_xy(x, y, zero)
|
|
1174
1175
|
self.cache_xy = [x, y]
|
|
@@ -1318,7 +1319,8 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
1318
1319
|
def __add__(self, other):
|
|
1319
1320
|
einfo = self.r_obj('function(){return this["toString"]()}', objectId=self.objectId, returnByValue=False)
|
|
1320
1321
|
return self.f._parse_js2py(einfo, self, iso=self.iso) + str(other)
|
|
1321
|
-
|
|
1322
|
+
html = property(lambda s:s['outerHTML'] or s['textContent'])
|
|
1323
|
+
text = property(lambda s:s['textContent'])
|
|
1322
1324
|
previous = property(lambda s:s['previousElementSibling'])
|
|
1323
1325
|
next = property(lambda s:s['nextElementSibling'])
|
|
1324
1326
|
parent = property(lambda s:s['parentElement'])
|
|
@@ -1913,7 +1915,7 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
1913
1915
|
class DOM:
|
|
1914
1916
|
def __init__(self, f):
|
|
1915
1917
|
self.f = f
|
|
1916
|
-
self.f.cdp('DOM.enable')
|
|
1918
|
+
# self.f.cdp('DOM.enable') # only call api. not listen events, no need enable.
|
|
1917
1919
|
class Cache:
|
|
1918
1920
|
def __init__(self, f):
|
|
1919
1921
|
self.f = f
|
|
@@ -1926,8 +1928,9 @@ def cdp_client(hostname, port, debug=False, runtimeEnable=False, cfg={}):
|
|
|
1926
1928
|
self._cache_cdp(sessionId)
|
|
1927
1929
|
self.is_enable = True
|
|
1928
1930
|
def _cache_cdp(self, sessionId):
|
|
1929
|
-
self.f.cdp('Network.enable', sessionId=sessionId)
|
|
1930
|
-
self.f.cdp('Storage.enable', sessionId=sessionId)
|
|
1931
|
+
# self.f.cdp('Network.enable', sessionId=sessionId) # only call api. not listen events, no need enable.
|
|
1932
|
+
# self.f.cdp('Storage.enable', sessionId=sessionId) # only call api. not listen events, no need enable.
|
|
1933
|
+
pass
|
|
1931
1934
|
def attach(self, f):
|
|
1932
1935
|
f.clear_cache = self.clear_cache
|
|
1933
1936
|
def add_cache_session(self, sessionId):
|
|
@@ -2802,6 +2805,7 @@ class Chrome:
|
|
|
2802
2805
|
userAgent = property(lambda s:s.get_userAgent(), lambda s,v:s.set_userAgent(v))
|
|
2803
2806
|
languages = property(lambda s:s.get_languages(), lambda s,v:s.set_languages(v))
|
|
2804
2807
|
platform = property(lambda s:s.get_platform(), lambda s,v:s.set_platform(v))
|
|
2808
|
+
html = property(lambda s:s['document']['documentElement']['outerHTML'])
|
|
2805
2809
|
return Chrome(self.root, self.dr.root._new_driver(not foreground))
|
|
2806
2810
|
frames = property(lambda s:s.dr.frames)
|
|
2807
2811
|
cookies = property(lambda s:s.get_cookies(), lambda s,v:s.set_cookies(v))
|
|
@@ -2809,6 +2813,7 @@ class Chrome:
|
|
|
2809
2813
|
userAgent = property(lambda s:s.get_userAgent(), lambda s,v:s.set_userAgent(v))
|
|
2810
2814
|
languages = property(lambda s:s.get_languages(), lambda s,v:s.set_languages(v))
|
|
2811
2815
|
platform = property(lambda s:s.get_platform(), lambda s,v:s.set_platform(v))
|
|
2816
|
+
html = property(lambda s:s['document']['documentElement']['outerHTML'])
|
|
2812
2817
|
def _check_lower_version(self):
|
|
2813
2818
|
try:
|
|
2814
2819
|
version = self.dr.root.version
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
v/__init__.py,sha256=6ZddLaDcwLudHWmFr2utAcYhperXw9AYoItNPm8EZSM,65
|
|
2
|
+
vchrome/__init__.py,sha256=jSrnEZLp3_atYOrh3Sd-QF2n1ynTIwIuCGXnuXIR_DM,227216
|
|
3
|
+
vchrome-0.1.9.dist-info/METADATA,sha256=s8cXPtNAplO0IEcCir-q9X-souSVzmAR4ocahqNlCFw,56
|
|
4
|
+
vchrome-0.1.9.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
|
|
5
|
+
vchrome-0.1.9.dist-info/top_level.txt,sha256=IYbkbnFb2FGoroYj_ZXIitmnJDgYBA29_HmK9BdEUkY,10
|
|
6
|
+
vchrome-0.1.9.dist-info/RECORD,,
|
vchrome-0.1.7.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
v/__init__.py,sha256=6ZddLaDcwLudHWmFr2utAcYhperXw9AYoItNPm8EZSM,65
|
|
2
|
-
vchrome/__init__.py,sha256=Pmp8KIUPMjdmW-t6iyYnYy329l074Z7Y2FOVcCH2aL8,226660
|
|
3
|
-
vchrome-0.1.7.dist-info/METADATA,sha256=g050rIVhk4jDo9duVobzL5OzMeQbyPErnIhiWZgtb4U,56
|
|
4
|
-
vchrome-0.1.7.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
|
|
5
|
-
vchrome-0.1.7.dist-info/top_level.txt,sha256=IYbkbnFb2FGoroYj_ZXIitmnJDgYBA29_HmK9BdEUkY,10
|
|
6
|
-
vchrome-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|