Skip to content

Commit 47eaab3

Browse files
authored
Merge pull request #206 from ctripcorp/main_click_xy
add step for click x,y
2 parents 4ef929b + d66ba00 commit 47eaab3

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

flybirds/core/dsl/globalization/i18n.py

+1
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,6 @@
209209
"开启服务[{service}]绑定MockCase[{mock_case_id}]"],
210210
"touch[{selector}]": ["点触[{selector}]"],
211211
"touch text[{selector}]": ["点触文本[{selector}]"],
212+
"click ele [{selector}] position[{x},{y}]": ["点击元素[{selector}]位置[{x},{y}]"],
212213
},
213214
}

flybirds/core/dsl/step/element.py

+13
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,16 @@ def touch_text(context, selector=None):
511511
:param selector: locator string for selector element (or None).
512512
"""
513513
g_Context.step.touch_text(context, selector)
514+
515+
516+
@step("click ele [{selector}] position[{x},{y}]")
517+
@ele_wrap
518+
def click_ele_point(context, selector, x=None, y=None):
519+
"""
520+
Click on the screen coordinates
521+
:param context: step context
522+
:param selector: locator string for selector element (or None)
523+
:param x: Coordinate x-axis
524+
:param y: Coordinate y-axis.
525+
"""
526+
g_Context.step.click_ele_point(context, selector, int(float(x)), int(float(y)))

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

+4
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,7 @@ def touch_text(self, context, param):
279279
param = "text=" + param
280280
locator, timeout = self.get_ele_locator(param)
281281
locator.tap(timeout=timeout)
282+
283+
def ele_click_point(self, context, param, x, y):
284+
locator, timeout = self.get_ele_locator(param)
285+
locator.click(timeout=timeout, position={"x": x, "y": y})

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

+5
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,8 @@ def ele_touch(cls, context, selector):
355355
def touch_text(cls, context, selector):
356356
ele = gr.get_value("plugin_ele")
357357
ele.touch_text(context, selector)
358+
359+
@classmethod
360+
def click_ele_point(cls, context, selector, x, y):
361+
ele = gr.get_value("plugin_ele")
362+
ele.ele_click_point(context, selector, x, y)

0 commit comments

Comments
 (0)