Я не могу перетащить селен в последний Chrome.selenium = '3.141.0' python 3.7 Chrome = 74.0.3729.169 ChromeDriver = последний
Ниже код успешно выполнен, но элементы не перетаскиваются из источника в пункт назначения, и я также не получаю никакой ошибки вообще.Я попробовал все нижеприведенное решение один за другим, но ни один из них не работал вообще.
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time
cd = webdriver.Chrome('Chromedriver.exe')
cd.get('https://www.seleniumeasy.com/test/drag-and-drop-demo.html')
cd.maximize_window()
elements = cd.find_element_by_id('todrag')
drag_item = elements.find_elements_by_tag_name('span')
drag_to = cd.find_element_by_id('mydropzone')
for i in drag_item:
action = ActionChains(cd)
#solution 1 not wroking
action.drag_and_drop(i, drag_to).perform() # this is not working
#solution 2 not working
ActionChains(cd).click_and_hold(i).move_to_element(drag_to).release(
drag_to).perform()
#solution 3 not working for this u need to download the js files
jquery_url = "http://code.jquery.com/jquery-1.11.2.min.js"
with open("jquery_load_helper.js") as f:
load_jquery_js = f.read()
with open("drag_and_drop_helper.js") as f:
js = f.read()
cd.execute_async_script(load_jquery_js, jquery_url)
cd.execute_script(js + "$(\'arguments[0]\').simulateDragDrop({ dropTarget: \"arguments[1]\"});", i, drag_to)