Skip to content

Commit 08906a0

Browse files
authored
Merge pull request #224 from ctripcorp/main_yls_operationandscroll
feat: Web 支持语句:1. 页面没有请求[] 2. 移动元素[]至可视区域
2 parents d273a23 + bf705e3 commit 08906a0

File tree

7 files changed

+60
-2
lines changed

7 files changed

+60
-2
lines changed

flybirds/core/dsl/globalization/i18n.py

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
"向{param1}扫描[{selector}]的文案"],
171171
"from {param1} find[{selector}]image": [
172172
"向{param1}查找[{selector}]的图像"],
173+
"move element[{selector}]to view": ["移动元素[{selector}]至可视区域"],
173174
"unblock the current page": ["解除当前页面限制"],
174175
"current page is [{param}]": ["当前页面是[{param}]"],
175176
"current page is not last page": ["当前页面已不是上一个指定页面"],
@@ -202,6 +203,7 @@
202203
"is [{expect_value}]": [
203204
"验证服务[{service}]的请求参数[{target_json_path}]"
204205
"与[{expect_value}]一致"],
206+
"page not requested [{service}]": ["页面没有请求[{service}]"],
205207
"compare target element [{target_element}] with compared picture [{compared_picture_path}]": [
206208
"对比图片元素[{target_element}]和基准图片路径[{compared_picture_path}]"],
207209
"compare target element[{target_ele}] with compared text path of [{compared_text_path}]": [

flybirds/core/dsl/step/element.py

+10
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ def full_screen_swipe_to_img(context, param1=None, selector=None):
451451
"""
452452
g_Context.step.full_screen_swipe_to_img(context, param1, selector)
453453

454+
@step("move element[{selector}]to view")
455+
@ele_wrap
456+
def scroll_ele_into_view(context, selector=None):
457+
"""
458+
Full screen swipe in the specified direction to find the specified
459+
selector element
460+
:param context: step context
461+
:param selector: locator string for selector element (or None).
462+
"""
463+
g_Context.step.scroll_ele_into_view(context, selector)
454464

455465
@step("clear [{selector}] and input[{param2}]")
456466
@ele_wrap

flybirds/core/dsl/step/request.py

+12
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ def request_compare(context, service=None, target_data_path=None):
140140
g_Context.step.request_compare_from_path(context, service,
141141
target_data_path)
142142

143+
@step(
144+
"page not requested [{service}]"
145+
)
146+
@ele_wrap
147+
def page_not_requested(context, service=None):
148+
"""
149+
compare and verify the request's post body with the data of the target path
150+
151+
:param context: step context
152+
:param service: service request name. (string or None).
153+
"""
154+
g_Context.step.page_not_requested(context, service)
143155

144156
@step(
145157
"compare service request [{service}] with xml file [{target_data_xml_path}]"

flybirds/core/global_resource.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def init_glb():
3535
"interceptionRequest": {},
3636
"interceptionValues": {},
3737
"browser_context": None,
38-
"web_context_hook": None
38+
"web_context_hook": None,
39+
"operate_record": {},
3940
}
4041

4142

flybirds/core/plugin/plugins/default/web/interception.py

+12
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ def request_compare(operation, target_data_path):
255255
# Call the handle_diff() function to compare the differences between the actual request object
256256
# and the expected request object, and output the log
257257
handle_diff(actual_request_obj, expect_request_obj, operation, target_data_path)
258+
259+
@staticmethod
260+
def page_not_requested(operation):
261+
request_info = get_server_request_opetate(operation)
262+
if request_info:
263+
message = f'[pageNotRequested] the request [{operation}] has been requested'
264+
raise FlybirdsException(message)
258265

259266
@staticmethod
260267
def request_query_string_compare(operation, target_data_path):
@@ -609,6 +616,11 @@ def get_server_request_body(service):
609616
return interception_request.get(service)
610617
return None
611618

619+
def get_server_request_opetate(service):
620+
operate_record = gr.get_value('operate_record')
621+
if operate_record:
622+
return operate_record.get(service)
623+
return None
612624

613625
def handle_ignore_node(service):
614626
exclude_paths = []

flybirds/core/plugin/plugins/default/web/page.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,15 @@ def handle_request(request):
380380
if operation is not None and len(operation.strip()) > 0:
381381
interception_request = gr.get_value('interceptionRequest')
382382
request_body = interception_request.get(operation)
383-
383+
# 记录页面请求
384+
operate_record = gr.get_value('operate_record')
385+
operate_record[operation] = {
386+
'method': request.method,
387+
'postData': request.post_data,
388+
'url': request.url,
389+
'updateTimeStamp': int(round(time.time() * 1000))
390+
}
391+
gr.set_value("operate_record", operate_record)
384392
if request_body is not None:
385393
log.info(
386394
f'[handle_request] start cache service:{operation}')

flybirds/core/plugin/plugins/default/web/step.py

+13
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ def full_screen_swipe_to_ele_aaa(cls, context, param_1, selector):
239239
ele = gr.get_value("plugin_ele")
240240
ele.find_full_screen_slide(context, param_1, selector)
241241

242+
@classmethod
243+
def scroll_ele_into_view(cls, context, selector):
244+
"""
245+
from {param1} find[{param2}]element
246+
"""
247+
ele = gr.get_value("plugin_ele")
248+
ele.find_full_screen_slide(context, None, selector)
249+
242250
@classmethod
243251
def ele_attr_equal(cls, context, selector, param2, param3):
244252
ele = gr.get_value("plugin_ele")
@@ -312,6 +320,11 @@ def clear_all_request_mock(context):
312320
@staticmethod
313321
def request_compare_from_path(context, operation, target_data_path):
314322
request_op.request_compare(operation, target_data_path)
323+
324+
@staticmethod
325+
def page_not_requested(context, operation):
326+
request_op.page_not_requested(operation)
327+
315328

316329
@staticmethod
317330
def request_query_str_compare_from_path(context, operation,

0 commit comments

Comments
 (0)