squish - Squish moveMouse 返回错误:移动鼠标失败
问题描述
我正在使用 Squish 6.3.0 Beta 版来测试用 Qt 编写的应用程序(我知道有更新的版本,但目前无法进行升级)。我正在尝试移动鼠标以获取工具提示,但 mouseMove 命令返回 RuntimeError: Failed to move the mouse。包装器函数是python中的编写器代码heretten:
def mouse_move(self, object_name, x, y, timeout=None):
try:
my_obj = waitForObject(object_name, timeout)
logging.debug("Found object: {0}".format(my_obj.objectName))
mouseMove(my_obj, x, y)
logging.debug("Mouse moved to: {object_name}".format(object_name=my_obj.objectName))
except Exception, e:
logging.error("Error: {0}".format(e))
ex_type, ex_value, ex_traceback = sys.exc_info()
trace_back = traceback.extract_tb(ex_traceback)
stack_trace = list()
for trace in trace_back:
stack_trace.append(
"File : %s , Line : %d, Func.Name : %s, Message : %s" % (trace[0], trace[1], trace[2], trace[3]))
logging.error("Exception type: {0}".format(ex_type.__name__))
logging.error("Exception message: {0}".format(ex_value))
logging.error("Stack trace: {0}".format(stack_trace))
我得到的输出:
16:19:11 DEBUG: Found object: name_of_the_object
16:19:11 ERROR: Error: Failed to move the mouse
16:19:11 ERROR: Exception type: RuntimeError
16:19:11 ERROR: Exception message: Failed to move the mouse
16:19:11 ERROR: Stack trace: path/my_squish_wrapper.py , Line : 170, Func.Name : mouse_move, Message : mouseMove(my_obj, x, y)']
有谁知道为什么鼠标不能移动?或者我应该检查什么以获得更多信息。
解决方案
如果有人需要,我已经找到了解决此 mouseMove 问题的方法:
rect = object.globalBounds(my_obj)
x = rect.center().x
y = rect.center().y
QCursor.setPos(x, y)
推荐阅读
- r - xaringan code output same style as bookdown
- agda - 在命令行使用 Agda 2.5.4.2 编译 Hello World 时出错
- java - JVM 线程是否会始终保持其到 OS 线程的映射
- ios - How to upload image in Swift using Moya?
- winforms - SkiaSharp:如何限制或降低大(4K)屏幕的绘图像素分辨率?
- php - 未定义索引但索引存在
- typescript - Typescript 类型中的嵌套三元条件扩展
- python - Get value from xml response in Python
- c# - EF Core:更新一对多关系依赖实体 id
- java - 没有可用的“javax.persistence.EntityManager”类型的合格 bean: