good. cld u pls do a video on drag and drop by offset.
@rajpriya7862 жыл бұрын
How can i drag and drop or choose a file from desktop. Can you please help here
@AnaSantosSJC Жыл бұрын
I wanna know how can I do this too
@Anusha12162 ай бұрын
I tried with the same. I took a single row from some table instead of image. Dragging is working but it is not dropping
@CodersArcade2 ай бұрын
If you're using the Robot Framework with the Selenium Library and facing issues with drag-and-drop where dragging works but dropping does not, you can try the following approaches to resolve it: 1. Use JavaScript for Drag and Drop Sometimes using JavaScript can bypass issues with the standard Selenium drag-and-drop method. You can execute JavaScript code to perform the drag-and-drop operation: *** Settings *** Library SeleniumLibrary *** Variables *** ${DRAG_ELEMENT} xpath=//element-to-drag ${DROP_TARGET} xpath=//drop-target-element *** Test Cases *** Drag And Drop Using JavaScript Open Browser yourwebsite.com browser=chrome ${drag_element}= Get WebElement ${DRAG_ELEMENT} ${drop_target}= Get WebElement ${DROP_TARGET} Execute JavaScript var dataTransfer = new DataTransfer(); \ var dragStartEvent = new DragEvent('dragstart', { dataTransfer: dataTransfer }); \ arguments[0].dispatchEvent(dragStartEvent); \ var dropEvent = new DragEvent('drop', { dataTransfer: dataTransfer }); \ arguments[1].dispatchEvent(dropEvent); \ var dragEndEvent = new DragEvent('dragend', { dataTransfer: dataTransfer }); \ arguments[0].dispatchEvent(dragEndEvent); \ return true; \ ;${drag_element} ;${drop_target} Close Browser 2. Verify Drop Target Readiness Ensure the drop target is ready to receive the dragged element. You might need to wait until the drop target is fully loaded or visible: *** Test Cases *** Drag And Drop With Wait Open Browser yourwebsite.com browser=chrome Wait Until Element Is Visible ${DROP_TARGET} Drag And Drop ${DRAG_ELEMENT} ${DROP_TARGET} Close Browser 3. Check for Element Overlap or Hidden Elements Make sure that the drop target is not covered by any other elements and is not hidden. You can use the `Get Element Attribute` keyword to check visibility or positioning: *** Test Cases *** Check Drop Target Visibility Open Browser yourwebsite.com browser=chrome ${is_displayed}= Get Element Attribute ${DROP_TARGET} style Should Contain ${is_displayed} display: block Drag And Drop ${DRAG_ELEMENT} ${DROP_TARGET} Close Browser 4. Use Built-In Selenium Keywords for Drag and Drop Ensure you're using the correct syntax for the `Drag And Drop` keyword. Here's an example: *** Test Cases *** Drag And Drop Using Selenium Open Browser yourwebsite.com browser=chrome Drag And Drop ${DRAG_ELEMENT} ${DROP_TARGET} Close Browser 5. Debugging Add logging and debugging to ensure you are targeting the correct elements and that they are interactable: *** Test Cases *** Debug Drag And Drop Open Browser yourwebsite.com browser=chrome ${drag_element}= Get WebElement ${DRAG_ELEMENT} ${drop_target}= Get WebElement ${DROP_TARGET} Log Drag Element: ${drag_element} Log Drop Target: ${drop_target} Drag And Drop ${DRAG_ELEMENT} ${DROP_TARGET} Close Browser By following these steps, you should be able to troubleshoot and resolve issues related to drag-and-drop operations using the Robot Framework Selenium Library. Let me know if you need further assistance!