Selenium driver Python drag and drop, element is dropped where is pointer and not dropping area

一世执手 提交于 2020-06-17 14:01:06

问题


The drag action is working, but instead of drop in the selected area, drop on mouse pointer position. Someone has any idea? Thanks

def test_drag_action_to_tsb(self, driver):
    source_element = driver.find_element_by_xpath('//*[@id="bzm-action-builder-tabs-tabpane-ACTION"]/ul/li[1]')
    base.wait_for_element(driver, By.CLASS_NAME, 'scriptless-scenarios-steps-panel')
    dest_element = driver.find_element_by_class_name(self, 'scriptless-scenarios-steps-panel')
    ActionChains(driver).click_and_hold(source_element).move_to_element(dest_element).release(dest_element).perform()
    time.sleep(5)
    assert base.is_text_present(driver, 'is Required')
    time.sleep(5)

回答1:


Depending on selenium documentation following codes should work :

ActionChains(driver). drag_and_drop(source_element, dest_element).perform()


来源:https://stackoverflow.com/questions/59735440/selenium-driver-python-drag-and-drop-element-is-dropped-where-is-pointer-and-no

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!