MCPcopy Create free account
hub / github.com/a943512/PyAibote / WebLoadWait

Class WebLoadWait

PyAibote/WebBotModel/WebLoadWait.py:5–83  ·  view source on GitHub ↗

隐式等待和显示等待 Implicit waiting and explicit waiting

Source from the content-addressed store, hash-verified

3
4
5class WebLoadWait:
6 """
7 隐式等待和显示等待
8 Implicit waiting and explicit waiting
9 """
10
11 Implicit_Waiting = 0
12 Implicit_Waiting_Frequency = 0
13 Implicit_Waiting_Throwing = False
14 Show_Waiting = 0
15 Show_Waiting_Frequency = 0
16 Show_Waiting_Throwing = False
17
18 def _Send(self,data):
19 self.debug(rf"->>> {data}")
20
21 self.request.sendall(data)
22 response = self.request.recv(87654)
23 if response == b"":
24 self.request.close()
25 raise ConnectionAbortedError(f"{self.client_address[0]}:{self.client_address[1]} Client disconnects")
26 data_length, data = response.split(b"/", 1)
27 while int(data_length) > len(data):
28 data += self.request.recv(87654)
29
30 response = data.decode('UTF-8')
31 if len(response) > 10000:
32 self.debug(rf"<-<- {response[:100]}......")
33 else:
34 self.debug(rf"<-<- {response}")
35 if response == b"":
36 self.request.close()
37 raise ConnectionAbortedError(f"{self.client_address[0]}:{self.client_address[1]} Client disconnects")
38 return response
39
40 def StarLoadWait(self, data):
41 response = self._Send(data)
42 start_time = time.time()
43 if 'false' in response or 'webdriver error' in response:
44 while time.time() - start_time < self.Implicit_Waiting:
45 try:
46 self.debug(rf"---- Cannot find element. Retrying.... No retry in {self.Implicit_Waiting}s {round(time.time() - start_time, 2)}s")
47 response = self._Send(data)
48 if 'false' not in response and 'webdriver error' not in response:
49 break
50 if "domain" in response or "path" in response or "secure" in response or "httpOnly" in response:
51 break
52 time.sleep(self.Implicit_Waiting_Frequency)
53 except Exception as e:
54 time.sleep(self.Implicit_Waiting_Frequency)
55 if self.Implicit_Waiting_Throwing:
56 if 'false' in response or 'webdriver error' in response:
57 self.request.close()
58 raise "Unable to find the specified element"
59 return response
60
61 def StartShowWait(self, Time: int, RotationTime: int, ThrowException: bool):
62 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected