sale-client 3.5.281 → 3.5.282
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.
- package/AutoTest/BasePage.py +42 -0
- package/AutoTest/Config.json +2 -0
- package/AutoTest/PublicScript.py +447 -0
- package/AutoTest/__init__.py +0 -0
- package/AutoTest/all_case/__init__.py +0 -0
- package/AutoTest/all_case/record/__init__.py +0 -0
- package/AutoTest/all_case/record/aa_PersonalAddScript.py +108 -0
- package/AutoTest/all_case/record/ac_Templatedownload.py +73 -0
- package/AutoTest/img/test_Aqianfcxkhquery.png +0 -0
- package/AutoTest/record_test_run.py +24 -0
- package/AutoTest/report//345/273/272/346/241/243/351/203/250/345/210/206/346/265/213/350/257/225/346/212/245/345/221/212.html +7312 -0
- package/AutoTest/requirements.txt +9 -0
- package/package.json +1 -1
- package/src/filiale/shanxian/components/FilesManage/MeterinfoTest.vue +7 -0
- package/src/filiale/shaoguan/IOTMeterCenter.vue +1 -1
- package/src/main.js +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
import unittest
|
|
3
|
+
from selenium import webdriver
|
|
4
|
+
from PublicScript import *
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
with open(file='./config.json', mode="r") as f:
|
|
8
|
+
params = json.load(f)
|
|
9
|
+
username = params["user"]
|
|
10
|
+
password = params["pwd"]
|
|
11
|
+
weburl = params["webUrl"]
|
|
12
|
+
print(username)
|
|
13
|
+
print(password)
|
|
14
|
+
print(weburl)
|
|
15
|
+
f.close()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class basepage(unittest.TestCase):
|
|
19
|
+
@classmethod
|
|
20
|
+
def set_driver(cls):
|
|
21
|
+
options = webdriver.ChromeOptions()
|
|
22
|
+
|
|
23
|
+
options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
|
|
24
|
+
options.add_argument('disable-infobars')
|
|
25
|
+
|
|
26
|
+
driver = webdriver.Chrome()
|
|
27
|
+
driver.maximize_window()
|
|
28
|
+
cls.driver = driver
|
|
29
|
+
driver.get(weburl)
|
|
30
|
+
driver.maximize_window()
|
|
31
|
+
|
|
32
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="用户名"]').send_keys(username)
|
|
33
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="密码"]').send_keys(password)
|
|
34
|
+
present_wait(driver, By.ID, 'login-button').click()
|
|
35
|
+
|
|
36
|
+
# sleep(3)
|
|
37
|
+
# if is_element_load(driver, '//button[@id="vc-messagebox-confirm"]'):
|
|
38
|
+
# present_wait(driver, By.XPATH, '//button[@id="vc-messagebox-confirm"]').click()
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def get_driver(cls):
|
|
42
|
+
return cls.driver
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from PIL import Image
|
|
3
|
+
from selenium.webdriver.common.by import By
|
|
4
|
+
from selenium.webdriver.support.wait import WebDriverWait
|
|
5
|
+
from selenium.webdriver.common.action_chains import ActionChains
|
|
6
|
+
from selenium.webdriver.support import expected_conditions as EC
|
|
7
|
+
from selenium.webdriver.support.wait import WebDriverWait
|
|
8
|
+
from time import sleep
|
|
9
|
+
import logging
|
|
10
|
+
import time
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# 点击当前页面中的查询按钮
|
|
14
|
+
def click_query(driver):
|
|
15
|
+
is_element_load(driver, '//div[@class = "list-flex flex"]/span')
|
|
16
|
+
span = driver.find_element_by_xpath('//div[@class = "list-flex flex"]/span')
|
|
17
|
+
querys = span.find_elements_by_tag_name('button')
|
|
18
|
+
for query in querys:
|
|
19
|
+
text = query.text
|
|
20
|
+
if text == '查询' or text == '查 询':
|
|
21
|
+
query.click()
|
|
22
|
+
break
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# 检查元素是否被加载到
|
|
26
|
+
def is_element_load(driver, xpath):
|
|
27
|
+
try:
|
|
28
|
+
WebDriverWait(driver, 2, 0.1).until(lambda d: driver.find_element_by_xpath(xpath), message=xpath + '加载超时')
|
|
29
|
+
return True
|
|
30
|
+
except:
|
|
31
|
+
return False
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# 如果有隐藏按钮,就点击
|
|
35
|
+
def click_hide(driver):
|
|
36
|
+
is_element_load(driver, '//div[@class = "list-flex flex"]/span')
|
|
37
|
+
span = driver.find_element_by_xpath('//div[@class = "list-flex flex"]/span')
|
|
38
|
+
divs = span.find_elements_by_tag_name('div')
|
|
39
|
+
for hide in divs:
|
|
40
|
+
text = hide.get_attribute('class')
|
|
41
|
+
# 关闭状态
|
|
42
|
+
if text == 'button_spacing button_shrink_bottom':
|
|
43
|
+
sleep(0.5)
|
|
44
|
+
hide.click()
|
|
45
|
+
break
|
|
46
|
+
# 打开状态
|
|
47
|
+
elif text == 'button_spacing button_shrink_top':
|
|
48
|
+
break
|
|
49
|
+
# 没有隐藏按钮
|
|
50
|
+
else:
|
|
51
|
+
continue
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# 判断元素是否存在
|
|
55
|
+
def is_element_exist(browser, element):
|
|
56
|
+
try:
|
|
57
|
+
browser.find_element_by_xpath(element)
|
|
58
|
+
return True
|
|
59
|
+
except:
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def isset(v):
|
|
64
|
+
try:
|
|
65
|
+
type(eval(v))
|
|
66
|
+
except:
|
|
67
|
+
return 0
|
|
68
|
+
else:
|
|
69
|
+
return 1
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# 关闭当前页面
|
|
73
|
+
def close_page(driver):
|
|
74
|
+
move = driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[3]/div/article/div/div[2]/div[1]/'
|
|
75
|
+
'div[2]/div/div/div/ul/li/a/span')
|
|
76
|
+
ActionChains(driver).move_to_element(move).perform()
|
|
77
|
+
if is_element_load(driver, '/html/body/div[1]/div[1]/div/div[3]/div/article/div/div[2]/div[1]/'
|
|
78
|
+
'div[2]/div/div/div/ul/li/a/span'):
|
|
79
|
+
driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[3]/div/article/div/div[2]/div[1]/'
|
|
80
|
+
'div[2]/div/div/div/ul/li/a/span').click()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def make_regalur_image(img, size=(256, 256)):
|
|
84
|
+
# 将图片尺寸强制重置为指定的size大小
|
|
85
|
+
# 然后再将其转换成RGB值
|
|
86
|
+
return img.resize(size).convert('RGB')
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def split_image(img, part_size=(8, 8)):
|
|
90
|
+
# 将图片按给定大小切分
|
|
91
|
+
w, h = img.size
|
|
92
|
+
pw, ph = part_size
|
|
93
|
+
assert w % pw == h % ph == 0
|
|
94
|
+
return [img.crop((i, j, i + pw, j + ph)).copy() \
|
|
95
|
+
for i in range(0, w, pw) for j in range(0, h, ph)]
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def hist_similar(lh, rh):
|
|
99
|
+
# 统计切分后每部分图片的相似度频率曲线
|
|
100
|
+
assert len(lh) == len(rh)
|
|
101
|
+
return sum(1 - (0 if l == r else float(abs(l - r)) / max(l, r)) \
|
|
102
|
+
for l, r in zip(lh, rh)) / len(lh)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def calc_similar(li, ri):
|
|
106
|
+
# 计算两张图片的相似度
|
|
107
|
+
return sum(hist_similar(l.histogram(), r.histogram()) \
|
|
108
|
+
for l, r in zip(split_image(li), split_image(ri))) / 1024.0
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def calc_similar_by_path(lf, rf):
|
|
112
|
+
li, ri = make_regalur_image(Image.open(lf)), \
|
|
113
|
+
make_regalur_image(Image.open(rf))
|
|
114
|
+
return calc_similar(li, ri)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# 判断元素是否可点击
|
|
118
|
+
def is_element_can_click(element):
|
|
119
|
+
try:
|
|
120
|
+
element.is_enabled()
|
|
121
|
+
return True
|
|
122
|
+
except:
|
|
123
|
+
return False
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def see_results(driver):
|
|
127
|
+
doquery(driver)
|
|
128
|
+
click_query(driver)
|
|
129
|
+
is_element_load(driver, '//div[@class = "list-flex flex"]/span')
|
|
130
|
+
span = driver.find_element_by_xpath('//div[@class = "list-flex flex"]/span')
|
|
131
|
+
querys = span.find_elements_by_tag_name('button')
|
|
132
|
+
print(len(querys))
|
|
133
|
+
for query in querys:
|
|
134
|
+
print(query.text)
|
|
135
|
+
text = query.text
|
|
136
|
+
if text == '清空' or text == '清 空':
|
|
137
|
+
query.click()
|
|
138
|
+
print('点 击 了 清 空')
|
|
139
|
+
break
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def doquery(driver):
|
|
143
|
+
click_hide(driver)
|
|
144
|
+
# 填写查询条件
|
|
145
|
+
write_condition(driver)
|
|
146
|
+
click_query(driver)
|
|
147
|
+
sleep(1)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# 填写查询条件
|
|
151
|
+
def write_condition(driver):
|
|
152
|
+
input_group1 = driver.find_elements_by_xpath('//div[@class="col-sm-2 form-group"]/input')
|
|
153
|
+
input_group2 = driver.find_elements_by_xpath('//div[@class="form-group col-sm-2"]/input')
|
|
154
|
+
input_group3 = driver.find_elements_by_xpath('//div[@class="col-sm-2"]/input')
|
|
155
|
+
input_group4 = driver.find_elements_by_xpath('//div[@class="col-sm-3"]/input')
|
|
156
|
+
input_group5 = driver.find_elements_by_xpath('//div[@class="form-group form-input-group"]/input')
|
|
157
|
+
|
|
158
|
+
for input1 in input_group1:
|
|
159
|
+
input1.send_keys('111')
|
|
160
|
+
|
|
161
|
+
for input2 in input_group2:
|
|
162
|
+
input2.send_keys('111')
|
|
163
|
+
|
|
164
|
+
for input3 in input_group3:
|
|
165
|
+
input3.send_keys('111')
|
|
166
|
+
|
|
167
|
+
for input4 in input_group4:
|
|
168
|
+
input4.send_keys('111')
|
|
169
|
+
|
|
170
|
+
for input5 in input_group5:
|
|
171
|
+
input5.send_keys('111')
|
|
172
|
+
|
|
173
|
+
# 选择下拉框
|
|
174
|
+
select_group1 = driver.find_elements_by_xpath('//div[@class="col-sm-2 form-group"]')
|
|
175
|
+
select_group2 = driver.find_elements_by_xpath('//div[@class="form-group col-sm-2"]')
|
|
176
|
+
select_group3 = driver.find_elements_by_xpath('//div[@class="col-sm-2"]')
|
|
177
|
+
select_group4 = driver.find_elements_by_xpath('//div[@class="form-group col-sm-3"]')
|
|
178
|
+
select_group5 = driver.find_elements_by_xpath('//div[@class="form-group col-sm-2"]')
|
|
179
|
+
|
|
180
|
+
for select1 in select_group1:
|
|
181
|
+
if is_element_exist(select1, 'label'):
|
|
182
|
+
if select1.find_element_by_tag_name('label').text != '组织机构':
|
|
183
|
+
if select1.find_elements_by_tag_name('button'):
|
|
184
|
+
sleep(1)
|
|
185
|
+
select1.click()
|
|
186
|
+
element = './/ul/li'
|
|
187
|
+
if is_element_exist(select1, element):
|
|
188
|
+
select1.find_element_by_xpath('.//ul/li[2]').click()
|
|
189
|
+
|
|
190
|
+
for select2 in select_group2:
|
|
191
|
+
if is_element_exist(select2, 'label'):
|
|
192
|
+
if select2.find_element_by_tag_name('label').text != '组织机构':
|
|
193
|
+
if select2.find_elements_by_tag_name('button'):
|
|
194
|
+
sleep(1)
|
|
195
|
+
select2.click()
|
|
196
|
+
element = './/ul/li'
|
|
197
|
+
if is_element_exist(select2, element):
|
|
198
|
+
select2.find_element_by_xpath('.//ul/li[2]').click()
|
|
199
|
+
|
|
200
|
+
for select3 in select_group3:
|
|
201
|
+
if is_element_exist(select3, 'label'):
|
|
202
|
+
if select3.find_element_by_tag_name('label').text != '组织机构':
|
|
203
|
+
if select3.find_elements_by_tag_name('button'):
|
|
204
|
+
sleep(1)
|
|
205
|
+
select3.click()
|
|
206
|
+
element = './/ul/li'
|
|
207
|
+
if is_element_exist(select3, element):
|
|
208
|
+
select3.find_element_by_xpath('.//ul/li[2]').click()
|
|
209
|
+
|
|
210
|
+
for select4 in select_group4:
|
|
211
|
+
if is_element_exist(select4, 'label'):
|
|
212
|
+
if select4.find_element_by_tag_name('label').text != '组织机构':
|
|
213
|
+
if select4.find_elements_by_tag_name('button'):
|
|
214
|
+
sleep(1)
|
|
215
|
+
select4.click()
|
|
216
|
+
element = './/ul/li'
|
|
217
|
+
if is_element_exist(select4, element):
|
|
218
|
+
select4.find_element_by_xpath('.//ul/li[2]').click()
|
|
219
|
+
|
|
220
|
+
for select5 in select_group5:
|
|
221
|
+
if is_element_exist(select5, 'label'):
|
|
222
|
+
if select5.find_element_by_tag_name('label').text != '组织机构':
|
|
223
|
+
if select5.find_elements_by_tag_name('button'):
|
|
224
|
+
sleep(1)
|
|
225
|
+
select5.click()
|
|
226
|
+
element = './/ul/li'
|
|
227
|
+
if is_element_exist(select5, element):
|
|
228
|
+
select5.find_element_by_xpath('.//ul/li[2]').click()
|
|
229
|
+
|
|
230
|
+
# 选择日期
|
|
231
|
+
date_group1 = driver.find_elements_by_xpath('//div[@class="col-sm-2 form-group"]/div[@class = "datepicker"]')
|
|
232
|
+
date_group2 = driver.find_elements_by_xpath('//div[@class="form-group col-sm-2"]/div[@class = "datepicker"]')
|
|
233
|
+
|
|
234
|
+
for date1 in date_group1:
|
|
235
|
+
sleep(0.5)
|
|
236
|
+
date1.click()
|
|
237
|
+
sleep(0.5)
|
|
238
|
+
ActionChains(driver).move_to_element_with_offset(date1, 120, 120).click().perform()
|
|
239
|
+
|
|
240
|
+
for date2 in date_group2:
|
|
241
|
+
print(' date2已找到 ')
|
|
242
|
+
sleep(0.5)
|
|
243
|
+
date2.click()
|
|
244
|
+
sleep(0.5)
|
|
245
|
+
print('date2已点击')
|
|
246
|
+
ActionChains(driver).move_to_element_with_offset(date2, 120, 120).click().perform()
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
# 显示等待 对应find_element
|
|
250
|
+
def present_wait(driver, fun, path):
|
|
251
|
+
element = WebDriverWait(driver, 5, 0.5).until(EC.visibility_of_element_located((fun, path)))
|
|
252
|
+
return element
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
# 显示等待 对应find_elements
|
|
256
|
+
def present_waits(driver, fun, path):
|
|
257
|
+
element = WebDriverWait(driver, 5, 0.5).until(EC.presence_of_all_elements_located((fun, path)))
|
|
258
|
+
return element
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def find_li(driver):
|
|
262
|
+
top_list = []
|
|
263
|
+
button_group = present_waits(driver, By.XPATH, '//ul[@role="tablist"]//button')
|
|
264
|
+
for button in button_group:
|
|
265
|
+
if button.is_displayed():
|
|
266
|
+
top_list.append(button.text)
|
|
267
|
+
return top_list
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
# 关闭当前页面
|
|
271
|
+
def close_current_page(driver):
|
|
272
|
+
print('关闭页面')
|
|
273
|
+
close_page = present_wait(driver, By.XPATH, '//li[@class="bg-info active"]')
|
|
274
|
+
ActionChains(driver).move_to_element(close_page).perform()
|
|
275
|
+
CloseX = WebDriverWait(driver, 5, 0.5).until(EC.element_to_be_clickable((By.ID, 'vc-tabset-close-vuestrap-0')))
|
|
276
|
+
CloseX.click()
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def area_choose(driver):
|
|
280
|
+
sleep(0.5)
|
|
281
|
+
if is_element_load(driver, '//span[text()="选择小区"]'):
|
|
282
|
+
area_group = present_waits(driver, By.XPATH, '//span[text()="选择小区"]')
|
|
283
|
+
for area in area_group:
|
|
284
|
+
if area.is_displayed() and area.is_enabled():
|
|
285
|
+
sleep(0.5)
|
|
286
|
+
area.click()
|
|
287
|
+
sleep(0.5)
|
|
288
|
+
last_choose = present_wait(driver, By.XPATH, '//div[@class="btn-group select_list select '
|
|
289
|
+
'open"]//ul/li[last()]//a[last()]')
|
|
290
|
+
if last_choose.is_displayed() and last_choose.is_enabled():
|
|
291
|
+
last_choose.click()
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
# 提示框操作
|
|
295
|
+
def tips_ctrl(driver):
|
|
296
|
+
notice = present_wait(driver, By.XPATH, '//*[@id="app-base"]/div[2]/div/div/div/article')
|
|
297
|
+
print(notice.text)
|
|
298
|
+
submit = present_wait(driver, By.ID, 'vc-messagebox-confirm')
|
|
299
|
+
submit.click()
|
|
300
|
+
print(submit.text)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
# 输入框通用操作
|
|
304
|
+
def input_border(driver, xpath):
|
|
305
|
+
judge = is_element_load(driver, xpath)
|
|
306
|
+
if judge:
|
|
307
|
+
input_group1 = present_waits(driver, By.XPATH, xpath)
|
|
308
|
+
for input1 in input_group1:
|
|
309
|
+
if input1.is_displayed() and input1.is_enabled():
|
|
310
|
+
input1.send_keys('111')
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
# 下拉框通用操作
|
|
314
|
+
def choose_border(driver, xpath):
|
|
315
|
+
border = is_element_load(driver, xpath)
|
|
316
|
+
if border:
|
|
317
|
+
select_group1 = present_waits(driver, By.XPATH, xpath)
|
|
318
|
+
for select1 in select_group1:
|
|
319
|
+
if select1.is_enabled() and select1.is_displayed():
|
|
320
|
+
select1.click()
|
|
321
|
+
element = './/ul/li'
|
|
322
|
+
if is_element_exist(select1, element):
|
|
323
|
+
last_one = select1.find_element_by_xpath('.//ul/li[last()]/a')
|
|
324
|
+
if last_one.is_displayed():
|
|
325
|
+
last_one.click()
|
|
326
|
+
else:
|
|
327
|
+
select1.find_element_by_xpath('.//ul/li[2]/a').click()
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
# 按按钮名来点击按钮
|
|
331
|
+
def button_name_click(driver, name):
|
|
332
|
+
sleep(1)
|
|
333
|
+
button_group = present_waits(driver, By.XPATH, '//button[text()="' + name + '"]')
|
|
334
|
+
for button in button_group:
|
|
335
|
+
if button.is_displayed():
|
|
336
|
+
button.click()
|
|
337
|
+
break
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def input_name_sandkey(driver, name, name2):
|
|
341
|
+
present_wait(driver, By.XPATH, './/input[@placeholder="' + name + '"]').clear()
|
|
342
|
+
present_wait(driver, By.XPATH, './/input[@placeholder="' + name + '"]').send_keys(name2)
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def input_name_sandkeys(driver, name, name2):
|
|
346
|
+
present_waits(driver, By.XPATH, './/input[@placeholder="' + name + '"]')[1].clear()
|
|
347
|
+
present_waits(driver, By.XPATH, './/input[@placeholder="' + name + '"]')[1].send_keys(name2)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def fillin(driver, name):
|
|
351
|
+
sleep(0.5)
|
|
352
|
+
present_wait(driver, By.XPATH, ".//input[@placeholder='请输入搜索组织']").send_keys(name)
|
|
353
|
+
searchbuttons = present_waits(driver, By.XPATH, ".//div[@class='form-group']//button[text()='查询']")
|
|
354
|
+
for searchbutton in searchbuttons:
|
|
355
|
+
searchbutton.click()
|
|
356
|
+
break
|
|
357
|
+
sleep(1)
|
|
358
|
+
present_wait(driver, By.XPATH, './/a[@id="vc-tree-name-' + name + '"]/span').click()
|
|
359
|
+
confirmbuttons = present_waits(driver, By.XPATH, ".//button[text()='确认']")
|
|
360
|
+
for confirmbutton in confirmbuttons:
|
|
361
|
+
confirmbutton.click()
|
|
362
|
+
break
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
# 日期框通用操作
|
|
366
|
+
def data_border(driver, xpath):
|
|
367
|
+
data = is_element_load(driver, xpath)
|
|
368
|
+
if data:
|
|
369
|
+
date_group1 = present_waits(driver, By.XPATH, xpath)
|
|
370
|
+
for date1 in date_group1:
|
|
371
|
+
if date1.is_displayed() and date1.is_enabled():
|
|
372
|
+
date1.click()
|
|
373
|
+
sleep(0.5)
|
|
374
|
+
today = date1.find_element_by_xpath('.//button[text()="今天"]')
|
|
375
|
+
if today.is_displayed() and today.is_enabled():
|
|
376
|
+
today.click()
|
|
377
|
+
else:
|
|
378
|
+
group1 = date1.find_elements_by_xpath('.//span[text()="十月"]')
|
|
379
|
+
group2 = date1.find_elements_by_xpath('.//span[text()="2022"]')
|
|
380
|
+
for part in group1:
|
|
381
|
+
if part.is_displayed() and today.is_enabled():
|
|
382
|
+
part.click()
|
|
383
|
+
else:
|
|
384
|
+
for part2 in group2:
|
|
385
|
+
if part2.is_displayed() and today.is_enabled():
|
|
386
|
+
part2.click()
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
# 点击查询按钮操作
|
|
390
|
+
def search_button_click(driver):
|
|
391
|
+
search_buttons = present_waits(driver, By.XPATH, '//button[contains(text(),"查询")]')
|
|
392
|
+
for search_button in search_buttons:
|
|
393
|
+
if search_button.is_displayed():
|
|
394
|
+
search_button.click()
|
|
395
|
+
break
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
# 点击左侧id属性按钮
|
|
399
|
+
def id_click(driver, name):
|
|
400
|
+
present_wait(driver, By.ID, "vc-tree-name-" + name).click()
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
# 点击下拉箭头
|
|
404
|
+
def bottom_push_click(driver):
|
|
405
|
+
topbuttons = present_waits(driver, By.XPATH, '//div[@class="button_spacing button_shrink_bottom"]')
|
|
406
|
+
for topbutton in topbuttons:
|
|
407
|
+
if topbutton.is_displayed():
|
|
408
|
+
topbutton.click()
|
|
409
|
+
break
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
def criteria(driver, xpath):
|
|
413
|
+
click_hide(driver)
|
|
414
|
+
judge = is_element_load(driver, xpath)
|
|
415
|
+
if judge:
|
|
416
|
+
input_group1 = present_waits(driver, By.XPATH, xpath)
|
|
417
|
+
for input1 in input_group1:
|
|
418
|
+
if input1.is_displayed() and input1.is_enabled():
|
|
419
|
+
input1.send_keys('没数据就行')
|
|
420
|
+
break
|
|
421
|
+
click_query(driver)
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def action_charg(self, driver, imgname):
|
|
425
|
+
sleep(2)
|
|
426
|
+
driver.save_screenshot('./Image/newImage/' + imgname + '.png')
|
|
427
|
+
flag = os.path.exists('./Image/oldImage/' + imgname + '.png')
|
|
428
|
+
if flag:
|
|
429
|
+
percentage = calc_similar_by_path('./Image/newImage/' + imgname + '.png',
|
|
430
|
+
'./Image/oldImage/' + imgname + '.png') * 100
|
|
431
|
+
else:
|
|
432
|
+
driver.save_screenshot('./Image/oldImage/' + imgname + '.png')
|
|
433
|
+
percentage = calc_similar_by_path('./Image/newImage/' + imgname + '.png',
|
|
434
|
+
'./Image/oldImage/' + imgname + '.png') * 100
|
|
435
|
+
|
|
436
|
+
if percentage > 98:
|
|
437
|
+
print(str(round(percentage, 2)) + '%')
|
|
438
|
+
expcet_price = True
|
|
439
|
+
else:
|
|
440
|
+
print(imgname + '与原页面相似度为:' + str(round(percentage, 2)) + '%')
|
|
441
|
+
expcet_price = False
|
|
442
|
+
|
|
443
|
+
self.assertEqual(expcet_price, True)
|
|
444
|
+
if expcet_price:
|
|
445
|
+
print("预期结果与实际结果一致,测试通过")
|
|
446
|
+
driver.save_screenshot('./Image/oldImage/' + imgname + '.png')
|
|
447
|
+
close_current_page(driver)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import random
|
|
2
|
+
from BeautifulReport import BeautifulReport
|
|
3
|
+
from PublicScript import *
|
|
4
|
+
from BasePage import basepage
|
|
5
|
+
|
|
6
|
+
kh_name = '测试(脚本添加)'
|
|
7
|
+
number = random.randint(1, 1000000)
|
|
8
|
+
phone = random.randint(10000000000, 99999999999)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class aa_PersonalAddScript1(basepage):
|
|
12
|
+
def save_img(self, img_name):
|
|
13
|
+
self.driver.get_screenshot_as_file("./img/" + img_name + ".png")
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def setUpClass(cls):
|
|
17
|
+
cls.set_driver()
|
|
18
|
+
|
|
19
|
+
@BeautifulReport.add_test_img("test_Aybhjd")
|
|
20
|
+
def test_Aybhjd(self):
|
|
21
|
+
"""预备户建档"""
|
|
22
|
+
sleep(1)
|
|
23
|
+
global driver
|
|
24
|
+
driver = self.get_driver()
|
|
25
|
+
present_wait(driver, By.ID, "vc-tree-name-档案管理").click()
|
|
26
|
+
present_wait(driver, By.ID, "vc-tree-name-档案信息").click()
|
|
27
|
+
self.personal_add(driver)
|
|
28
|
+
|
|
29
|
+
@BeautifulReport.add_test_img("test_Bxh")
|
|
30
|
+
def test_Bxh(self):
|
|
31
|
+
"""建档后的用户进行销户处理"""
|
|
32
|
+
sleep(1)
|
|
33
|
+
close_current_page(driver)
|
|
34
|
+
present_wait(driver, By.ID, "vc-tree-name-预备户建档").click()
|
|
35
|
+
self.xiaohu(driver)
|
|
36
|
+
|
|
37
|
+
def test_zZZZ_END(self):
|
|
38
|
+
"""当前测试模块结束,关闭浏览器"""
|
|
39
|
+
driver.quit()
|
|
40
|
+
|
|
41
|
+
def personal_add(self, driver):
|
|
42
|
+
sleep(2)
|
|
43
|
+
present_wait(driver, By.XPATH, '//button[contains(text(),"单户建档")]').click()
|
|
44
|
+
present_wait(driver, By.XPATH, '//div[@class = "binary-right"]//span/button').click()
|
|
45
|
+
sleep(1)
|
|
46
|
+
present_wait(driver, By.XPATH, '//*[@id="vc-datagrid-name-0"]/td[2]/button').click()
|
|
47
|
+
print('点击了选择地址按钮')
|
|
48
|
+
input_border(driver, '//div[@class="col-sm-4 form-group"]/input')
|
|
49
|
+
input_border(driver, '//div[@class="col-sm-8 form-group"]/input')
|
|
50
|
+
data_border(driver, '//div[@class="datepicker"]')
|
|
51
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="客户名称"]').send_keys(kh_name)
|
|
52
|
+
present_wait(driver, By.XPATH, '//label[text()="*客户电话"]/following-sibling::*[1]').send_keys(phone)
|
|
53
|
+
|
|
54
|
+
input_border(driver, '//div[@class="col-sm-6 form-group"]/input')
|
|
55
|
+
choose_border(driver, '//div[@class="col-sm-4 form-group has-error"]//div[@class="btn-group"]')
|
|
56
|
+
present_wait(driver, By.XPATH, '//label[text()=" 表 号"]/following-sibling::*[1]').clear()
|
|
57
|
+
present_wait(driver, By.XPATH, '//label[text()=" 表 号"]/following-sibling::*[1]').send_keys(number)
|
|
58
|
+
present_wait(driver, By.XPATH, '//div[@class="form-group"]//button[contains(text(),"确认")]').click()
|
|
59
|
+
sleep(1)
|
|
60
|
+
result = is_element_load(driver, '//p[contains(text(),"错误码")]')
|
|
61
|
+
expect = '测试'
|
|
62
|
+
if not result:
|
|
63
|
+
print('建档功能未报错,测试通过')
|
|
64
|
+
expect = '建档功能未报错,测试通过'
|
|
65
|
+
else:
|
|
66
|
+
print('建档功能报错,测试失败')
|
|
67
|
+
self.assertEqual(expect, '建档功能未报错,测试通过')
|
|
68
|
+
|
|
69
|
+
def xiaohu(self, driver):
|
|
70
|
+
sleep(1)
|
|
71
|
+
bottom_push_click(driver)
|
|
72
|
+
sleep(1)
|
|
73
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="客户电话"]').send_keys(phone)
|
|
74
|
+
sleep(1)
|
|
75
|
+
search_button_click(driver)
|
|
76
|
+
present_wait(driver, By.XPATH, '//*[@id="vc-datagrid-name-0"]/td[10]/button').click()
|
|
77
|
+
sleep(1)
|
|
78
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="证件号码"]').clear()
|
|
79
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="证件号码"]').send_keys("622456199602154468")
|
|
80
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="用户余额"]').clear()
|
|
81
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="用户余额"]').send_keys(0)
|
|
82
|
+
present_wait(driver, By.XPATH, '//div[@class="form-group"]//button[contains(text(),"确认")]').click()
|
|
83
|
+
close_current_page(driver)
|
|
84
|
+
id_click(driver, '预备户建档')
|
|
85
|
+
sleep(1)
|
|
86
|
+
bottom_push_click(driver)
|
|
87
|
+
sleep(1)
|
|
88
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="客户电话"]').send_keys(phone)
|
|
89
|
+
search_button_click(driver)
|
|
90
|
+
present_wait(driver, By.XPATH, '//button[contains(text(),"销户")]').click()
|
|
91
|
+
dishu = present_wait(driver, By.XPATH, '//label[text()="当前底数:"]/following-sibling::*[1]').text
|
|
92
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="表底数"]').send_keys(dishu)
|
|
93
|
+
print('填写的表底数为' + dishu)
|
|
94
|
+
present_wait(driver, By.CSS_SELECTOR, '[placeholder="请填写原因"]').send_keys('销户原因')
|
|
95
|
+
print('填写的销户原因为:销户原因')
|
|
96
|
+
|
|
97
|
+
present_wait(driver, By.XPATH, '//button[text()="确认"and @class="button_search"] ').click()
|
|
98
|
+
print('点击了确认按钮')
|
|
99
|
+
|
|
100
|
+
result = is_element_load(driver, '//p[contains(text(),"销户成功")]')
|
|
101
|
+
if result:
|
|
102
|
+
print('销户功能未报错,测试通过')
|
|
103
|
+
else:
|
|
104
|
+
print('销户功能报错,测试失败')
|
|
105
|
+
self.assertEqual(result, True)
|
|
106
|
+
|
|
107
|
+
def tearDown(self):
|
|
108
|
+
pass
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from PublicScript import *
|
|
2
|
+
from BasePage import basepage
|
|
3
|
+
from BeautifulReport import BeautifulReport
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ac_Templatedownload1(basepage):
|
|
7
|
+
def save_img(self, img_name):
|
|
8
|
+
self.driver.get_screenshot_as_file("./img/" + img_name + ".png")
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def setUpClass(cls):
|
|
12
|
+
cls.set_driver()
|
|
13
|
+
|
|
14
|
+
@BeautifulReport.add_test_img("test_Adownload1")
|
|
15
|
+
def test_Adownload1(self):
|
|
16
|
+
"""建档功能"""
|
|
17
|
+
sleep(2)
|
|
18
|
+
global driver
|
|
19
|
+
driver = self.get_driver()
|
|
20
|
+
id_click(driver, "档案管理")
|
|
21
|
+
id_click(driver, "档案信息")
|
|
22
|
+
sleep(1)
|
|
23
|
+
self.personal_add(driver)
|
|
24
|
+
close_current_page(driver)
|
|
25
|
+
|
|
26
|
+
def test_zZZZ_END(self):
|
|
27
|
+
"""当前测试模块结束,关闭浏览器"""
|
|
28
|
+
driver.quit()
|
|
29
|
+
|
|
30
|
+
def personal_add(self, driver):
|
|
31
|
+
sleep(2)
|
|
32
|
+
topbuttons = present_waits(driver, By.XPATH, '//div[@class="button_spacing button_shrink_bottom"]')
|
|
33
|
+
for topbutton in topbuttons:
|
|
34
|
+
if topbutton.is_displayed():
|
|
35
|
+
topbutton.click()
|
|
36
|
+
break
|
|
37
|
+
userstate = present_wait(driver, By.XPATH, '//label[text()="客户状态"]/following-sibling::div')
|
|
38
|
+
userstate.click()
|
|
39
|
+
lis = userstate.find_elements_by_xpath('.//ul/li')
|
|
40
|
+
print(len(lis))
|
|
41
|
+
sleep(3)
|
|
42
|
+
# //label[text()="客户状态"]/following-sibling::div/ul/li
|
|
43
|
+
# present_wait(driver, By.XPATH, '//button[contains(text(),"单户建档")]').click()
|
|
44
|
+
# present_wait(driver, By.XPATH, '//div[@class = "binary-right"]//span/button').click()
|
|
45
|
+
# sleep(1)
|
|
46
|
+
# present_wait(driver, By.XPATH, '//*[@id="vc-datagrid-name-0"]/td[2]/button').click()
|
|
47
|
+
# print('点击了选择地址按钮')
|
|
48
|
+
# input_border(driver, '//div[@class="col-sm-4 form-group"]/input')
|
|
49
|
+
# input_border(driver, '//div[@class="col-sm-8 form-group"]/input')
|
|
50
|
+
# data_border(driver, '//div[@class="datepicker"]')
|
|
51
|
+
# present_wait(driver, By.CSS_SELECTOR, '[placeholder="客户名称"]').send_keys(kh_name)
|
|
52
|
+
# present_wait(driver, By.XPATH, '//label[text()="*客户电话"]/following-sibling::*[1]').send_keys(phone)
|
|
53
|
+
#
|
|
54
|
+
# input_border(driver, '//div[@class="col-sm-6 form-group"]/input')
|
|
55
|
+
# choose_border(driver, '//div[@class="col-sm-4 form-group has-error"]//div[@class="btn-group"]')
|
|
56
|
+
# present_wait(driver, By.XPATH, '//label[text()=" 表 号"]/following-sibling::*[1]').clear()
|
|
57
|
+
# present_wait(driver, By.XPATH, '//label[text()=" 表 号"]/following-sibling::*[1]').send_keys(number)
|
|
58
|
+
# present_wait(driver, By.XPATH, '//div[@class="form-group"]//button[contains(text(),"确认")]').click()
|
|
59
|
+
# sleep(1)
|
|
60
|
+
result = is_element_load(driver, '//p[contains(text(),"错误码")]')
|
|
61
|
+
expect = '测试'
|
|
62
|
+
if not result:
|
|
63
|
+
print('建档功能未报错,测试通过')
|
|
64
|
+
expect = '建档功能未报错,测试通过'
|
|
65
|
+
else:
|
|
66
|
+
print('建档功能报错,测试失败')
|
|
67
|
+
self.assertEqual(expect, '建档功能未报错,测试通过')
|
|
68
|
+
|
|
69
|
+
def close_error(self):
|
|
70
|
+
close_page = present_wait(driver, By.XPATH, '//*[@id="app-base"]/div[3]/div/button/span')
|
|
71
|
+
ActionChains(driver).move_to_element(close_page).perform()
|
|
72
|
+
sleep(0.5)
|
|
73
|
+
present_wait(driver, By.XPATH, '//*[@id="app-base"]/div[3]/div/button/span').click()
|
|
Binary file
|