硒2:moveByOffset()和连续release()-奇怪的位置 [英] Selenium 2: moveByOffset() and consecutive release() - strange positioning

查看:309
本文介绍了硒2:moveByOffset()和连续release()-奇怪的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Selenium 2与FirefoxDriver结合使用.任务是将元素移动几个像素.我以这种方式编写任务:

I'm using Selenium 2 with FirefoxDriver. The task is to move an element for a few pixels. I code the task this way:

val action = (new Actions(driver)).clickAndHold(el).moveByOffset(3,1).release().perform()

记录

mouseDown(),mouseMove()和mouseUp()事件.因此,我收到以下输出:

mouseDown(), mouseMove() and mouseUp() events are logged. So I receive the following output:

mouseDown at 267 133
mouseMove at 270 134
mouseMove at 267 133
mouseUp at 267 133

Selenium似乎在项目上调用mouseDown,然后将其移动到指定位置,然后将其移回,然后调用mouseUp.真是奇怪.

It looks like that Selenium calls mouseDown on the item, then moves it to the specified position, then moves it back and then calls mouseUp. That's pretty strange.

事实证明,原因是在release()调用中,因为当我这样调用时:

It turns out that the reason is in release() call, since when I call this:

val action = (new Actions(driver)).clickAndHold(el).moveByOffset(3,1).perform()

我明白了:

mouseDown at 267 133
mouseMove at 270 134

如何使Selenium在正确的位置调用mouseUp?

How to make Selenium to call mouseUp at the right position?

推荐答案

听起来像是虫子...一种可能的解决方法是:

Sounds like a bug... A possible workaround would be:

val action =(new Actions(driver)).dragAndDropToOffset(el,el.Location.X + 3,el.Location.Y +1).perform()

val action = (new Actions(driver)).dragAndDropToOffset(el, el.Location.X + 3, el.Location.Y + 1).perform()

这篇关于硒2:moveByOffset()和连续release()-奇怪的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆