gpt4 book ai didi

Ferrum mouse.up doesn't work for click & drag method(Ferrum Mouse.Up不适用于单击并拖动方法)

转载 作者:bug小助手 更新时间:2023-10-28 09:53:22 32 4
gpt4 key购买 nike



I'm writing a test which runs over Cuprite::Ferrum, where I need to click, drag and drop an element below another element on the page. Which works fine while I am doing it manually, but when i try to put it in a test, it almost work, but not quite.

我正在编写一个测试,它在Cuprite::Ferrum上运行,我需要在其中单击一个元素,并将其拖放到页面上另一个元素的下方。当我手动操作时,它工作得很好,但当我尝试将其放在测试中时,它几乎可以工作,但并不完全有效。


I was unable to find he drag and drop API for Ferrum or Cuprite, so I created something like:

我找不到Ferrum或Cuprite的拖放API,所以我创建了如下内容:


  def click_and_drag(draggable, droppable, offset_x, offset_y)
x1, y1 = draggable.native.node.find_position
x2, y2 = droppable.native.node.find_position

mouse = page.driver.browser.mouse
mouse.move(x: x1, y: y1)
mouse.down
mouse.move(x: x2 + offset_x, y: y2 + offset_y)
mouse.up
end

Pretty simple and works fine until it get to the mouse.up part. The element that needs to be picked up is found by the draggable = page.find(element), and it needs to be dropped below the droppable = page.find(element).

非常简单,并且运行得很好,直到鼠标向上部分。需要拾取的元素是通过draggable=page.find(元素)找到的,需要将其放在Droppable=page.find(元素)下面。


Everything is going great until the method gets to the mouse.up part, where the dragged element should be dropped and put in it's new place, but it just goes back to it starting position.

在方法到达Mouse.up部分之前,一切都很顺利,在该部分中,被拖动的元素应该被放到它的新位置,但它只是回到了它的起始位置。


I am referring to the Ferrum doc https://www.rubydoc.info/gems/ferrum/0.5/Ferrum/Mouse but cant seam to find the answer.

我指的是费伦文件https://www.rubydoc.info/gems/ferrum/0.5/Ferrum/Mouse,但不能缝找到答案。


更多回答
优秀答案推荐

So, the method works and all is well, the problem was with offset_x and offset_y, if you somehow find this and want to use it, keep it in mid, and keep them small!

所以,这个方法很有效,一切都很好,问题出在Offset_x和Offset_y上,如果您以某种方式找到了它并想要使用它,请将它放在中间,并使它们保持较小!


更多回答

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com