Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add step for click x,y #206

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flybirds/core/dsl/globalization/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,6 @@
"开启服务[{service}]绑定MockCase[{mock_case_id}]"],
"touch[{selector}]": ["点触[{selector}]"],
"touch text[{selector}]": ["点触文本[{selector}]"],
"click ele [{selector}] position[{x},{y}]": ["点击元素[{selector}]位置[{x},{y}]"],
},
}
13 changes: 13 additions & 0 deletions flybirds/core/dsl/step/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,16 @@ def touch_text(context, selector=None):
:param selector: locator string for selector element (or None).
"""
g_Context.step.touch_text(context, selector)


@step("click ele [{selector}] position[{x},{y}]")
@ele_wrap
def click_ele_point(context, selector, x=None, y=None):
"""
Click on the screen coordinates
:param context: step context
:param selector: locator string for selector element (or None)
:param x: Coordinate x-axis
:param y: Coordinate y-axis.
"""
g_Context.step.click_ele_point(context, selector, int(float(x)), int(float(y)))
4 changes: 4 additions & 0 deletions flybirds/core/plugin/plugins/default/web/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,7 @@ def touch_text(self, context, param):
param = "text=" + param
locator, timeout = self.get_ele_locator(param)
locator.tap(timeout=timeout)

def ele_click_point(self, context, param, x, y):
locator, timeout = self.get_ele_locator(param)
locator.click(timeout=timeout, position={"x": x, "y": y})
5 changes: 5 additions & 0 deletions flybirds/core/plugin/plugins/default/web/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,8 @@ def ele_touch(cls, context, selector):
def touch_text(cls, context, selector):
ele = gr.get_value("plugin_ele")
ele.touch_text(context, selector)

@classmethod
def click_ele_point(cls, context, selector, x, y):
ele = gr.get_value("plugin_ele")
ele.ele_click_point(context, selector, x, y)