-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute.py
More file actions
73 lines (61 loc) · 2.25 KB
/
Copy pathexecute.py
File metadata and controls
73 lines (61 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : execute.py
# @Author: shijiu
# @Date : 2020/9/4
# @SoftWare : PyCharm
class ExecuteClass():
def __init__(self, parent, step_list):
self.parent = parent
self.step_list = step_list
self.message = None
def execute_core(self):
print(self.step_list)
types = {'wait': self.do_wait, 'find': self.do_find, 'write': self.do_write, 'click': self.do_click,
'jump': self.do_jump, 'get': self.do_get, 'jumpWindow': self.do_jump_window}
for action in self.step_list:
method = types.get(action['actionType']) # type = 0 1 2 ...
if method:
isgo = method(action)
if isgo:
continue # 如果返回True, 表示该步骤执行完毕
else:
self.message = '第 %s 步出错。请检查参数。' % (int(action['fatherId']) + 1)
break
def do_wait(self, action):
print(action)
print("这是等待步骤")
self.parent.sfc.is_wait(action['xpath'])
return True
def do_find(self, action):
print(action)
print("这是查找元素")
self.parent.sfc.find_ele(action['xpath'])
return True
def do_write(self, action):
print(action)
print("这是写入数据")
self.parent.sfc.input_any(action['xpath'], action['value'])
return True
def do_click(self, action):
print(action)
print("这是点击步骤")
self.parent.sfc.click_in(action['xpath'])
return True
def do_jump(self, action):
print(action)
print("这是iframe窗口切换")
self.parent.current_frame = action['xpath']
self.parent.sfc.switch_win(action['xpath'])
return True
def do_get(self, action):
print("这是登录")
self.parent.sfc.get_url(action['url'])
self.parent.sfc.init_iframe()
return True
def do_jump_window(self, action):
print(action)
print("跳转页面")
self.parent.sfc.switch_to_window(action['value'])
self.parent.sfc.init_iframe()
return True