selenium python 驱动程序,函数:move_to_element_with_offset 不正确的行为

2024-04-10

我遇到了 selenium python 驱动程序的问题,函数:move_to_element_with_offset 看来该功能只能将鼠标移动到元素的中间

def setUp(self):

    print "hello"
    self.logger = setuplogging()
    self.browser = webdriver.Firefox()

def _test_add_point(self):

    body = self.browser.find_element_by_tag_name("body")

    body.send_keys(Keys.UP * 20)
    applet = self.browser.find_element_by_id("selected-applet")
    pics = applet.find_elements_by_xpath(".//div[contains(@class, 'picture')]")

    time.sleep(5)
    real_pic = pics[0].find_elements_by_xpath(".//img")
    action_chains = ActionChains(self.browser)


    action_chains.move_to_element_with_offset(real_pic[0], 20, 20).perform()
    time.sleep(5)
    action_chains.click().perform()
    time.sleep(10)

当我执行上面的代码时,它总是会单击到图片的中间,而我的期望是在这种情况下它会单击到中心加上偏移量 (20, 20)。改变偏移量没有帮助。使用函数 move_by_offset 也没有帮助。

能否请你帮忙?


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

selenium python 驱动程序,函数:move_to_element_with_offset 不正确的行为 的相关文章

随机推荐