问题描述
我正在使用 appium 在 python 脚本中为 android 应用程序编写测试用例.我想在特定的边界/坐标中执行点击/点击操作.但是我做不到.谁能告诉我怎么做.
I am writing testcases in python script for android application using appium. I want to perform click/tap operation in a particular bounds/co-ordinates. but I am not able to perform it.Can any one tell me how to do it.
class firstTest(unittest.TestCase):
class firstTest(unittest.TestCase):
def tearDown(self):
"Tear down the test"
self.driver.quit()
def test_single_player_mode(self):
time.sleep(5)
element = self.driver.find_element_by_name("Enter your Email ID or User name")
element.send_keys("username")
element = self.driver.find_element_by_name("Let's get started!")
element.click()
time.sleep(5)
直到'让我们开始它工作正常.在 UI 之后,我没有任何元素名称或 ID.我只有特定的绑定才能单击该元素.我想点击绑定 [918,154][1086,324] 资源ID 上面绑定是com.abc.android.cap:id/friends_selection_list" 请告诉我之后怎么做.
Till 'Lets get started it is working fine. After it in UI, I don't have any element name or id. I have only particular bound to click the element. I want to click on bound [918,154][1086,324] resource ID for above bound is "com.abc.android.cap:id/friends_selection_list" Please tell me how to do after it.
推荐答案
你可以通过 触摸操作.
action = TouchAction(self.driver)
action.tap(element=None, x=100, y=600, count=2).perform()
或者像这样:
self.driver.tap([(100,600)], 500)
其中第一个变量是最多 5 个 x,y 坐标的列表(例如 self.driver.tap([(495,757), (200,500)], 500)
.最后一个数字是点击的持续时间.
Where the first variable is a list of up to 5 x,y coordinates(e.g. self.driver.tap([(495,757), (200,500)], 500)
. The last number is duration of the tap.
这篇关于如何使用appium对Android UI的python脚本中的垂直边界/坐标执行点击/点击操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!