果皮龙头不需要元素?

2024-09-28 21:57:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码点击屏幕中央。我不想触碰任何元素。只是在中心解散一些开放的小组。我该怎么做?在

 touch = TouchAction()
 dimension = driver.get_window_size()
 touch.tap(element=None, x=int(dimension['width']/2),y=int(dimension['height']/2)).perform()

上面的代码会产生这个错误

^{pr2}$

解决方案

在上面的代码中,初始化TouchAction()时缺少驱动程序作为参数 所以我要做的就是

touch = TouchAction(driver)

代码在…之后起作用了。。。。在


Tags: 代码元素sizeget屏幕driver小组tap
1条回答
网友
1楼 · 发布于 2024-09-28 21:57:11

可以使用TouchAction,示例在python客户端github页面上

el = self.driver.find_element_by_accessibility_id('Animation')
action = TouchAction(self.driver)
action.tap(el).perform()
el = self.driver.find_element_by_accessibility_id('Bouncing Balls')
self.assertIsNotNone(el)

也可以使用坐标(Java示例)

^{pr2}$

希望对您有所帮助;)

相关问题 更多 >