问题
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