- 主题:问个selenium的问题
for x, y in param:
center_x = int(x) - div_size['width'] / 2
center_y = int(y) - div_size['height'] / 2
logging.info("click at (%.2f, %.2f)" % (center_x, center_y))
action_chains.move_to_element_with_offset(element, center_x,
center_y).click().perform()
time.sleep(random.randint(0, 10) / 10)
按文档说move_to_element_with_offset是Move the mouse by an offset of the
specified element. Offsets are relative to the top-left corner of the element.
但是我这里必须以element中心为原点才能成功呢?
--
FROM 119.139.199.*
【 在 iwannabe 的大作中提到: 】
: for x, y in param:
: center_x = int(x) - div_size['width'] / 2
: center_y = int(y) - div_size['height'] / 2
: ...................
按文档说move_to_element_with_offset是Move the mouse by an offset of the
specified element. Offsets are relative to the top-left corner of the element.
但是我这里必须以element中心为原点才能成功呢?
不明白你在说啥, 这代码挺正常的, x, y 是什么意思? 是element的坐标,也许。
你说的你的代码是什么?
--
FROM 124.126.1.*
偏移量是相对于元素的左上角,你传的貌似是相对于中心的距离,鼠标实际移动的位置符合预期吗
【 在 iwannabe 的大作中提到: 】
: for x, y in param:
: center_x = int(x) - div_size['width'] / 2
: center_y = int(y) - div_size['height'] / 2
: ...................
--
FROM 222.128.40.*
4.xx之后ms是中心为原点,但是看代码里仍然写的是左上
【 在 Pharoah 的大作中提到: 】
: 偏移量是相对于元素的左上角,你传的貌似是相对于中心的距离,鼠标实际移动的位置
: 符合预期吗
--
FROM 120.229.14.*