【问题标题】:Selenium-python drag and drop not workingSelenium-python 拖放不起作用
【发布时间】:2019-10-16 12:16:49
【问题描述】:

我尝试使用 selenium 自动执行拖放选项 但下面的代码工作正常,没有错误

source=driver.find_element(By.XPATH,"//source path")
dest=driver.find_element(By.XPATH,"//destination path")
action=ActionChains(driver)     
action.drag_and_drop(source,dest).perform()

问题:元素被移动到目的地,但它没有放在那里(光标仍然持有该元素) 并且不能执行更多的鼠标操作(例如:单击)

【问题讨论】:

    标签: python-3.x selenium selenium-webdriver drag-and-drop


    【解决方案1】:

    .click_and_hold尝试另一种方式:

    ActionChains(driver).click_and_hold(source).move_to_element(dest).release(dest).click(dest).perform()
    

    如果您只想移动而不点击元素,请删除 .click(dest)

    【讨论】:

    • 不,我试过了,但问题仍然没有解决
    • 可以分享网站吗?
    • 对不起,我做不到。那是私人网站
    猜你喜欢
    • 2021-11-21
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多